小编Kav*_*taC的帖子

RubyXL:如何将多个数据单元格添加到工作表中?

如何将整个单元格数组添加到一行中?我有这样的东西->

w = RubyXL::Workbook.new
w.add_worksheet("Test")
test_sheet = w["Test"]
test_sheet.add_cell(0, 0, "abc") #this adds abc to row 0 and column 0

arr = ["hello","again","hi","there"]
Run Code Online (Sandbox Code Playgroud)

有没有类似的东西

test_sheet.add_row(a)
Run Code Online (Sandbox Code Playgroud)

我可以在哪里将数组 arr 的所有内容转移到测试工作表中的一行,并将 a 的每个元素放在单独的单元格中?

ruby ruby-on-rails rubyxl

6
推荐指数
1
解决办法
2285
查看次数

如何在EXTJS中使用全局函数/实用程序类

我的代码结构如下 - >

MyApp-> app - > controller,model,store,shared(util-> Utility.js),view

我创建了以下实用工具类

Ext.define('MyApp.shared.util.Utilities', {

    myFunction : function (val, meta, rec) {
        //do something 
        return val;
    }
});
Run Code Online (Sandbox Code Playgroud)

我试图在我的网格中渲染列时调用myFunction,如下所示 - >

Ext.define('MyApp.view.MyGrid', {
        extend: 'Ext.grid.Panel',        

        initComponent: function() {
            var rendererFn = Ext.create('MyApp.shared.util.Utilities');

            this.columns = [{
                text: 'Col1',
                dataIndex: 'col1'
                renderer: rendererFn.myFunction
            };

            this.store = new MyApp.store.MyStore();
            this.store.load();
            this.callParent(arguments);
        }        
});
Run Code Online (Sandbox Code Playgroud)

这工作正常,但我想知道这是否是使用全局函数的正确方法.

extjs global-variables

2
推荐指数
1
解决办法
2286
查看次数

Ruby:带有嵌套参数的 http POST 不起作用

我正在尝试使用 POST 和嵌套参数进行 Http Basic 身份验证。虽然外部参数工作正常(class.name - ActionController::Parameters),但嵌套参数是字符串(class.name - String)这是我的代码 ->

require 'net/http'

uri = URI('http://example.com/bulb/')
req = Net::HTTP::Post.new(uri)
req.basic_auth 'mytest@somesite.com', 'mypassword'

req.set_form_data('first_params' => 'a', 'seconnd_params'=>'b', 'netsed_params'=>{'first_netsed'=>'c', 'second_nested'=>'d'}, 'commit'=>'Create Bulb', 'action'=>'create', 'controller'=>'bulb')

res = Net::HTTP.start(uri.hostname, uri.port) do |http|
  http.request(req)
end

case res
when Net::HTTPSuccess, Net::HTTPRedirection
  # OK  
else
  #failed
end
Run Code Online (Sandbox Code Playgroud)

我可以使用什么其他库来使嵌套参数工作而无需手动转换它们。我发现这set_form_data不适用于嵌套哈希

ruby-on-rails http basic-authentication

2
推荐指数
1
解决办法
551
查看次数