I want to pass collection_select a value with the link_to_remote method. When I did this, I got an internal server error. I am using Rails 2.3.8. My code:
<%= collection_select("event", "trainer_id", @trainers , :id, :name, {:prompt => 'Select a Trainer'}, {:onchange=> "#{link_to_remote(:url => {:controller => 'events', :action => 'find_new' }, :with=>"'trainer_id='+value")}"}) %>
Added
This my controller code:
def find_new
@trainers= Trainer.all
if ["0"].include?(params[:trainer_id])
render :partial=>'events/me'
else
render :partial=> 'events/something'
end
end
onchangewill expect javascript, you’re providing an HTMLaelement with yourlink_to_remote.I’m guessing you’d want to redirect the user to the page you selected?
There are cleaner ways to do this, Unobtrusive Javascript for one, but I think that’s what you’re looking for.