I have a collection_select dialog that I have for selecting Users on a
page.  I am wanting the selection to remember and display the last
selected user from the database.  Every time I refresh the page it is
going back to its default value even though the data has changed.  Is
there a way to tell it to take the data that appears in the database
and not reset the selection tag like it a new value.
Here is my code that I''m using.
 <% @users = User.list_all_testers %>
 <%= collection_select(:machine, :user_id, @users, :id, :fullname,
options = {:include_blank=>true}, html_options = {:onChange =>
remote_function(:update => "ajaxmessage", :url => {:action =>
''update_machine_user'',
            :controller =>
''manage_machines'',:id=>machine.id},:with=>"''users_id=''+this.value")})
%>
Thanks William
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Mukund
2008-Sep-09  10:28 UTC
Re: collection_select reseting selection whenever page refreshes
http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#M001753 I assume you have the Ajax and the update parts right. It is a question of populating the right value into @machine. On Sep 9, 2:03 am, Will <william_evan...-Cdg0nuESRUEQi57izRGoj0EOCMrvLtNR@public.gmane.org> wrote:> I have a collection_select dialog that I have for selecting Users on a > page. I am wanting the selection to remember and display the last > selected user from the database. Every time I refresh the page it is > going back to its default value even though the data has changed. Is > there a way to tell it to take the data that appears in the database > and not reset the selection tag like it a new value. > > Here is my code that I''m using. > <% @users = User.list_all_testers %> > <%= collection_select(:machine, :user_id, @users, :id, :fullname, > options = {:include_blank=>true}, html_options = {:onChange => > remote_function(:update => "ajaxmessage", :url => {:action => > ''update_machine_user'', > :controller => > ''manage_machines'',:id=>machine.id},:with=>"''users_id=''+this.value")}) > %> > > Thanks William--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Florian Zschetzsche
2008-Sep-30  14:45 UTC
Re: collection_select reseting selection whenever page refreshes
Mukund wrote:> http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#M001753 > > I assume you have the Ajax and the update parts right. It is a > question of populating the right value into @machine.This is NOT working. See http://rails.lighthouseapp.com/projects/8994/tickets/1138-collection_select-doesnt-select-current-choice for details. Id is a FixNum value while the selected value is transfered as a String value. So value and selected can never be the same in option_value_selected? If value is FixNum! -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---