Checkbox instead of dropdown

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??

<% @categories.each do |categorie| %> > <%= categorie.name %> <% end %>

Grtz…remco

On Oct 3, 2007, at 12:09 PM, Remco S. wrote:

   <option value="<%= categorie.id %>"
     <%= 'selected' if categorie.id == @recipe.categorie_id %>>
     <%= categorie.name %>
   </option>

<% end %>

Grtz…remco

Posted via http://www.ruby-forum.com/.

For this kind of question you should really check the Rails list.

Remco S. 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??

<% @categories.each do |categorie| %> > <%= categorie.name %> <% end %>

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs