Rails 複数選択check_box_tag 例
"undefined method 'merge'などのエラーについて
解決例:
= f.check_box(:kindergarten, {}, true, false)
注意!
= f.check_box ( :high, { :multiple => true }, true, false)のようにboxのあとスペースを入れるとエラー!
syntax error, unexpected ',', expecting ')' ...(( f.check_box ( :kindergarten, { :multiple => true }, true,...
などとなります。
例;
- @categories.each_with_index do |category,i|
= check_box_tag "category#{i+1}", category.id
= category.name
間違え:
/ = check_box_tag "question[category_ids]", category.id, @question.categories.include?(category)
/ = category.name
/ = check_box "question[category_ids]", category.id, @question.categories.include?(category)
/ = category.name
/ =f.check_box :category1, {}, true, false
/ 家庭学習
1
|
You are getting mixed up between two ways of generating a check box I think. The form builder version,
However, as @Santosh points out in the comments, you'd probably be better off having a pair of radio buttons if you want the object to be either male or female. |
||||
|
ーーーーーー他のリンク