I'm trying to pass params into my rails path helper but my current attempt is not working. Here is what I'm doing now:
<%= link_to "Pause Assignment", pause_account_complete_assignment_index_path(@assignment.current_timekeeper) %>
def pause
binding.pry
end
In the controller I'm looking for the params I passed in. But they are not found. Here is what is returned.
<ActionController::Parameters {"controller"=>"accounts/complete_assignment", "action"=>"pause"} permitted: false>
resources :complete_assignment, only: [:create, :destroy] do
get 'pause', on: :collection
end
It may have something to do with the fact I using on collection?
But, basically how do I pass @assigment.current_timkeeper
in the controller?
You should pass the extra params in hash syntax
<%= link_to "Pause Assignment", pause_account_complete_assignment_index_path(current_timekeeper: @assignment.current_timekeeper) %>
This will give you params like
<ActionController::Parameters {
"controller"=>"accounts/complete_assignment",
"action"=>"pause",
"current_timekeeper"=>"value_of_current_timekeeper"
} permitted: false>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.