Will Taylor
Will Taylor

Reputation: 2304

Redirect_to not sending object

As part of a logging in, I redirect back to the original controller and action if the User doesn't save. But the original controller isn't receiving the resource object.

In registrations_controller.rb

redirect_to m_signup_after_job_post_path(resource, job: params[:job_id])

In pages_controller.rb

def signup_after_job_post
  resource ||= User.new
  respond_with(resource)
end

Upvotes: 1

Views: 48

Answers (1)

smathy
smathy

Reputation: 27961

Although the helpers like something_path take the object itself, internally they just call the .id method of that object and pass only the ID into the route itself. So in the action that receives that route you will always need to do something like:

resource = User.find params[:id]

Upvotes: 1

Related Questions