Creating a link_to from a collection_select

42 views
Skip to first unread message

Brian Ekmark

unread,
Sep 13, 2012, 10:32:34 AM9/13/12
to rubyonra...@googlegroups.com
I want to be able to change one attribute of a link_to to be what is the current selection of the collection_select. And needless to say I can't quite figure it out.
 
app/views/tasks/show.html.erb
 
Who would you like to assign this task to?<br />
<%= link_to 'Myself', :controller => 'task_queues', :task_id => @task.id, :action => 'assign_to_me' %> |
Assign To:
<%= collection_select("assign", "user_id", @users, :id, :full_name )%>
<%= link_to 'Assign', :controller =>'task_queues', :task_id => @task.id, :user_id => ## Current Selection of the collection_select ##, :action => 'assign_to_other' %>
 
This action brings it across to another controller/model where I write the results to the task_queues database.
 
Any insight or assistance in this would be greatly apprecaited.
 
Thanks,
 
Brian

Brian Ekmark

unread,
Sep 17, 2012, 5:16:57 PM9/17/12
to rubyonra...@googlegroups.com
Shameless bump ... can anyone help on this?

Jim Ruther Nill

unread,
Sep 17, 2012, 8:18:48 PM9/17/12
to rubyonra...@googlegroups.com
You need to use javascript.  In jquery that would be

$('#assign_user_id').change(function() {
  $(this).next().attr('href', '/task_queues/#{@task.id}/assign_to_other/' + $('#assign_user_id :selected').val()
 
I'm not sure how your routes is setup so I'm not sure if I got your url right.

 
Thanks,
 
Brian

--
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 rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/k8K_pbExS-QJ.

For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
-------------------------------------------------------------
visit my blog at http://jimlabs.heroku.com
Reply all
Reply to author
Forward
0 new messages