Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PerezIgnacio/b5e5212852fcbcff5b5e9c8e9bc74a2c to your computer and use it in GitHub Desktop.
Save PerezIgnacio/b5e5212852fcbcff5b5e9c8e9bc74a2c to your computer and use it in GitHub Desktop.
RegistrationsController example using nested_attributes
class RegistrationsController < Devise::RegistrationsController
def create
@user = User.new(sign_up_params)
if @user.save
# ...
else
render json: @user.errors, status: :unprocessable_entity
end
end
private
def sign_up_params
params.require(:user).permit(:name, :email, :phone, :password, :password_confirmation,
user_request_attributes: user_request_params)
end
def user_request_params
[:min_price, :max_price, :rating, :discount, provider_ids: [], :warranty, :keywords]
end
# ...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment