Reputation: 369
My user visits an item show view and then is send to the signup-page (I use devise). On the signup page, I have the params (item_id) of the item he visited on the previous page. I want this item_id to be saved when the user makes his sign_up (like user.item_id). Here is how I tried to do it:
<input value="#{params[:item_id]}" type="hidden" name="user[item_id]" id="user_item_id">
When the user is saved, the item_id remains empty. What am I missing here? Here is what I put into my controller:
def configure_sign_up_params
devise_parameter_sanitizer.permit(:sign_up, keys: [:item_id])
end
Upvotes: 2
Views: 951
Reputation: 369
Here is how I fixed it:
class RegistrationsController < Devise::RegistrationsController
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:item_id])
end
end
Upvotes: 3
Reputation: 78
How you handling this in controller. Just sending a parameter won't solve your issue
Upvotes: 0