Projects habtm Tasks
On tasks/show.html.erb I have link_to "Add This Task To Project", new_project_path(:task => @task)
This passes the @task params to the new_project_path http://localhost:3000/projects/new?task=24
How do I ensure the default <select><option> in the Project#new form is my @task.title when the new_project_path is accessed in this way?
===Update===
I’m using the simple_form gem to generate the select element
= simple_form_for @project do |f|
= f.association :task, :collection => current_user.task.collect { |t| t.title }, :prompt => "Select workout"
From the simple_form README: “The association helper just invokes input under the hood, so all options available to :select, :radio and :check_boxes are also available to association.”
So I used this (http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-select) as a reference.
In your controller, since you received the task id through a GET request:
In your view:
See if that works. If not, try enclosing that last argument in curly braces to make it a hash. Let me know how it goes.