Hi,
I am a RoR newby. The code below shows the categorie names, in a
dropdown from the categories table and that works fine. But now i want
to show the categories through checkboxen. How can i realise that??
<select name="recipe[categorie_id]">
<% @categories.each do |categorie| %>
<option value="<%= categorie.id %>"
<%= 'selected' if categorie.id == @recipe.categorie_id %>>
<%= categorie.name %>
</option>
<% end %>
</select>
Grtz..remco
···
--
Posted via http://www.ruby-forum.com/.
For this kind of question you should really check the Rails list.
···
On Oct 3, 2007, at 12:09 PM, Remco Swoany wrote:
Hi,
I am a RoR newby. The code below shows the categorie names, in a
dropdown from the categories table and that works fine. But now i want
to show the categories through checkboxen. How can i realise that??
<select name="recipe[categorie_id]">
<% @categories.each do |categorie| %>
<option value="<%= categorie.id %>"
<%= 'selected' if categorie.id == @recipe.categorie_id %>>
<%= categorie.name %>
</option>
<% end %>
</select>
Grtz..remco
--
Posted via http://www.ruby-forum.com/\.
Remco Swoany wrote:
Hi,
I am a RoR newby. The code below shows the categorie names, in a
dropdown from the categories table and that works fine. But now i want
to show the categories through checkboxen. How can i realise that??
<select name="recipe[categorie_id]">
<% @categories.each do |categorie| %>
<option value="<%= categorie.id %>"
<%= 'selected' if categorie.id == @recipe.categorie_id %>>
<%= categorie.name %>
</option>
<% end %>
</select>
Grtz..remco
Check out the rails doc http://api.rubyonrails.org/
You would put the check_box inside an iteration. so..
<% @categories.each do |category| %>
<%= check_box(category, name) %>
<% end %>
~Jeremy
···
--
Posted via http://www.ruby-forum.com/\.