打印

rails的bug?

rails的bug?

对于checkbox,多选时,提交到服务器后应该取到一个数组,而用rails的params[:name]只能取到第一个值。

不知道这是不是rails的一个bug?!

ruby: 1.8.6
rails: 1.2.3
First they ignore you, then they laugh at you, then they fight you, then you win.

TOP

你怎么测试的,把测试代码放出来一下

TOP

引用:
原帖由 williamraym 于 2007-5-23 09:24 发表
你怎么测试的,把测试代码放出来一下
index.rhtml里面的代码:
复制内容到剪贴板
代码:
                <form id="test_form" method="post" action="/Index/ajax">
                <input type="text" id="name" name="name" value="">
                <input type="checkbox" id="ids" name="ids" value="aaa">
                <input type="checkbox" id="ids" name="ids" value="bbb">
                <input type="checkbox" id="ids" name="ids" value="ccc">
               
                <input type="submit" value="submit">
                </form>
index_controller.rb方法:
复制内容到剪贴板
代码:
        def ajax
                @ids = params[:ids]
                @ids.each {|n| puts n }
                puts @ids
                puts params
                render_text "The id is #{params[:ids]}"
        end
控制台输出:



页面:
复制内容到剪贴板
代码:
The id is aaa
开始只是想做一个ajax的测试,发现问题后,改成了最原始的方法,发现问题依旧

不知道是不是自己的写法有问题
附件: 您所在的用户组无法下载或查看附件
First they ignore you, then they laugh at you, then they fight you, then you win.

TOP

可以把rails实现的代码打开看看

TOP

把name="ids"改成ids[]试试

TOP

引用:
原帖由 rainchen 于 2007-5-25 17:36 发表
把name="ids"改成ids[]试试


通过!
First they ignore you, then they laugh at you, then they fight you, then you win.

TOP

下不了代码啊

TOP

引用:
原帖由 yuc1029 于 2008-2-19 16:22 发表
下不了代码啊
下什么代码?
First they ignore you, then they laugh at you, then they fight you, then you win.

TOP