Saturday, February 19, 2011

Re: [Rails] quick syntax question - newbie

I think you're looking for something like radio_group.  Based on your previous example, I would code it as:

<div>
  <%= f.radio_group :postType_id, PostType.all(:order => "name ASC").map {|pt| [ pt.id, pt.name ] }
</div>

On Sun, Feb 20, 2011 at 5:21 AM, oliver torres <senortowers@gmail.com> wrote:
Hi all, am writing a simple app that lets me pick a post type to go
under National or International.
the code bellow generates  a drop-down   from where I can pick the
options

<div>
  <%= f.collection_select :postType_id, PostType.all(:order => "name
ASC"), :id, :name %>
</div>

what would be the syntax for this if instead I wanted to have two
radio buttons
I search for some sample code but all i've found is only with hard
coded strings.

any idea how I can generate two radio buttons for:
O National
O International

?
any help will be greatly appreciated.
oli.

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


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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate