Created
January 31, 2020 17:02
-
-
Save PerezIgnacio/b5e5212852fcbcff5b5e9c8e9bc74a2c to your computer and use it in GitHub Desktop.
RegistrationsController example using nested_attributes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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