Problems with :onchange for radio_button_tag

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

<%= radio_button_tag ‘sort_by_last_name’, ‘false’,
:onchange => ‘#{remote_function(:url => {:action =>
“update_users”},
:with => “order=0”)}’ %> Sort by First name

<%= render :partial => 'users', :object => @users %>

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs