Hello,
I am new to rails and have a question about form.select. I understand the
examples that have a select drop down selections which map to a column in the
model''s database row. What I want to do is provide a drop down list
for selections which do not map to a single column in a row but which maps to
any one of the columns in the table.
The list would be defined in the model class, named say Book:
SORT_TYPES = [["id", "id"],
["price", "price"]
["color", "color"]]
The form would look something like:
<% form_for :book, :url => { :action => :sort } do |form|
%>
<%= form.select :sort_type,
Book::SORT_TYPES,
:prompt => "sort reviews
by"
%>
<%= submit_tag "Sort", :class =>
"submit" %>
<% end %>
When the form is submitted, the sort method of the Book_controller is called
and I want to trap the value the user chose from the drop down list of options,
each of which is a column in the books table. I know the sort method is called
but I can''t seem to get a value from the selection.
So the question is: How do I trap a value from a form.select which is not mapped
to a single column from a model''s table but to one of the
table''s columns? How about the select return any arbitrary value (one
not associated with a database table)?
Any help would be greatly appreciated.
Thanks for your time,
Dave Hackenyos
daveh-fGmLKZA2H1sAvxtiuMwx3w@public.gmane.org
Videx Inc. 1105 N. E. Circle Blvd. Corvallis OR 97330 (541) 758-0521
CONFIDENTIAL COMMUNICATION: The email message and any attachments are intended
only for the addressee. They may be privileged, confidential, and protected
from disclosure. If you are not the intended recipient, any dissemination,
distribution, or copying is expressly prohibited. If you received this email
message in error, please notify the sender immediately by replying to this
e-mail message or by telephone
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
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
-~----------~----~----~----~------~----~------~--~---