Forum: Ruby on Rails Select/Option selected value

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
43ec529783988dbd6fa48d6204799c9f?d=identicon&s=25 jschairb (Guest)
on 2005-12-15 18:15
(Received via mailing list)
I'm trying to get a select box to populate with the current option for
editing
purposes.  I can populate the box, but not with the currently selected
value.
I've read in the api where it says to do this:

      # Example with @post.person_id => 1:
      #   select("post", "person_id", Person.find_all.collect {|p| [
p.name,
p.id ] }, { :include_blank => true })

and

      # By default, post.person_id is the selected option.  Specify
:selected =>
        value to use a different selection
      # or :selected => nil to leave all options unselected

I have this in my view:

<%= select("impact", "guide_id", Guide.find_all.collect {|p| [p.acronym,
p.id ]
}, { :include_blank => true} ) %>

I know guide_id variable is set because in the tag before it I can show:

<%= impact.guide_id %>

I've even tried this, which just makes the box say "Please select" upon
load:

<%= select("impact", "guide_id", @guides, :id, :acronym, :selected =>
impact.guide_id) %>

I'm trying to do all this in a for loop.  I've seen where there appears
to be
some changed made to ActionPack in regards to this feature, but it seems
to be
only if I want to set the selected value to something other than
@variable.method.

http://dev.rubyonrails.org/ticket/1125
http://dev.rubyonrails.org/ticket/2991

Any help would be greatly appreciated.
36f6f2152b91c3cd3d1f1669d2cdb734?d=identicon&s=25 Joe Esposito (Guest)
on 2005-12-15 18:25
I'm having similar issues, and posted right after you :)... Keep an eye
on my thread, as I'll be following yours :)
36f6f2152b91c3cd3d1f1669d2cdb734?d=identicon&s=25 Joe Esposito (Guest)
on 2005-12-15 21:15
Joe Esposito wrote:
> I'm having similar issues, and posted right after you :)... Keep an eye
> on my thread, as I'll be following yours :)

My issues apparently stemmed from Firefox not fully reloading the page..
This topic is locked and can not be replied to.