I have been trying all the day to make it happen, initial display is fine , but I cannot redisplay the selected value once the choice is done in my select helper I setup my slector in a helper (need to include the first option ''all'', as a prompt is displayed only once.... in my partial def company_role_selection(selection=nil) roles= [[''all'', 0]] roles += company_roles.collect {|h| [ h.name, company_roles.index(h)]}.compact.uniq select(''role'', ''id'', roles, {:selected => selection} ,{:onchange => "$(''select_role'').submit()"}) end in my controller, I get the selection @selection = params[:role][:id] then I find and display the users... and I redisplay the page with the form and the list <% form_for(:user, :url => user_path(@user), :html => {:method => :get, :id => ''select_role'' }) do |f| %> <%= render :partial => ''select_role'' , :locals=>{:selection => @selection } -%> <% end %> <div id="hits" > <%= render :partial => ''index'' -%> </div> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Jul-09 09:30 UTC
Re: select helper still the worth thing in rails...
On Jul 9, 12:14 am, Erwin <yves_duf...-ee4meeAH724@public.gmane.org> wrote:> in my controller, I get the selection > @selection = params[:role][:id] >You probably need to convert that to an integer (since ''1'' != 1) Fred> </div>--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 9 juil, 11:30, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jul 9, 12:14 am, Erwin <yves_duf...-ee4meeAH724@public.gmane.org> wrote: > > > in my controller, I get the selection > > @selection = params[:role][:id] > > You probably need to convert that to an integer (since ''1'' != 1) > > Fred > > > </div>got it... that''s the point !! could not remember it.... thanks a lot --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---