Ruby on Rails Sunday, October 30, 2011

Hello,

I'm very new to rails and am trying to make a basic website where the
user select from a list of colors and gets results for things with those
colors from the database.


<%= form_tag("/fbcs", :method => "get") do %>

<%= check_box_tag(:qgreen) %>
<%= label_tag(:qgreen, "Green") %>

<%= check_box_tag(:qred) %>
<%= label_tag(:red, "Red") %>

<%= check_box_tag(:qblack) %>
<%= label_tag(:black, "Black") %>

<%= check_box_tag(:qorange) %>
<%= label_tag(:orange, "Orange") %>

<%= check_box_tag(:qwhite) %>
<%= label_tag(:white, "White") %>

<%= check_box_tag(:qyellow) %>
<%= label_tag(:yellow, "Yellow") %>

<%= check_box_tag(:qblue) %>
<%= label_tag(:blue, "Blue") %>

<%= submit_tag("Search") %>
<% end %>

is my form.

My database has boolean fields for these.


I have been able to get results with direct names using


@query = Fbc.where(:name => params[:qname])

but do not know how to successfully query my database with the form for
checkbox fields.

Any help or guidance is appreciated,
Thanks.

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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment