Ah, yes. Sorry about that. The radio_group method isn't a part of the
FormBuilder, so while you can still call it within the scope of the form_for
block, you can't call it the way I told you to.
You will need to call it similar to:
<%= form_for @post do |f| %>
...
<div>
<%= radio_group "post[postType_id]", PostType.all(:order => "name
ASC").map {|pt| [ pt.id, pt.name ] }
</div>
...
<% end -%>
This *should* work if you adjust the code to your particular situation, but
post back if not.
On Sun, Feb 20, 2011 at 3:48 PM, Jim Ruther Nill <[email protected]> wrote:
> it should be f.radio_button. more samples at
> http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-radio_button
>
>
> On Sun, Feb 20, 2011 at 10:29 PM, señor tower <[email protected]>wrote:
>
>> Chris, thanks.
>> but iam getting an this error after trying your code:
>>
>> *undefined method `radio_group' for
>> #<ActionView::Helpers::FormBuilder:0x1034d6800>*
>>
>> am not sure if it is because this is a rails 3 app?
>> I googled this error but noting seemed helpful
>>
>> <%= f.radio_group :postType_id, PostType.all(:order => "name ASC").map
>> {|pt| [ pt.id, pt.name ] }%>
>>
>> any further help will be great.
>>
>> oli.
>>
>>
>>
>>
>>
>>
>> On Sun, Feb 20, 2011 at 2:52 AM, Chris Kottom <[email protected]>wrote:
>>
>>> 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 <[email protected]>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 [email protected].
>>>> To unsubscribe from this group, send email to
>>>> [email protected].
>>>> 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 [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> 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 [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/rubyonrails-talk?hl=en.
>>
>
>
>
> --
> -------------------------------------------------------------
> visit my blog at http://jimlabs.heroku.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 [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> 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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.