Greetings,
I''ve been hitting my head to the wall over this for quite a while now
and don''t seem to be able to wrap my forementioned head around it.
Basically I have a list of users in a selection box and I have two radio
buttons: Sort by first name and sort by last name. This is what I have
in my view:
<%= radio_button_tag ''sort_by_last_name'',
''true'', :checked => true,
:onchange => ''#{remote_function(:url => {:action =>
"update_users"},
:with => "order=1")}'' %> Sort by Last
name<br />
<%= radio_button_tag ''sort_by_last_name'',
''false'',
:onchange => ''#{remote_function(:url => {:action =>
"update_users"},
:with => "order=0")}'' %> Sort by First name
<div id="users"><%= render :partial =>
''users'', :object => @users
%></div>
This is my partial view:
<%= collection_select(nil, :user_id, users, :id, :first_name,
{:prompt => "Select user"}) %>
And this is my controller function for update_users:
def update_users
if params[:order] == 1
users = User.all
else
users = User.first
end
render :update do |page|
page.replace_html ''users'', :partial =>
''users'', :object => users
end
end
Now I''ve found a few sources describing on how this should be done, but
I haven''t been able to get them to work for some unknown reason.
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.