Created
November 9, 2013 05:02
-
-
Save svisamsetty/7381882 to your computer and use it in GitHub Desktop.
Example of add user
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
def add_user | |
@result = Hash.new | |
@result['status'] = true | |
@result['error_messages'] = [ ] | |
@result['success_messages'] = [ ] | |
if params[:password] == params[:password_confirmation] | |
@user = User.new | |
@user.fist_name = params[:first_name] | |
@user.last_name = params[:last_name] | |
params[:first_name], | |
params[:last_name] params[:username] params[:email_address] params[:password] | |
if @user.save | |
@result['success_messages'].push("User added successfully") | |
else | |
@result['status'] &= false | |
@result['error_messages'].push("There was an error adding user") | |
end | |
else | |
@result['status'] &= false | |
@result['error_messages'].push("Passsword and Password confirmation do not match") | |
end | |
respond_to do |format| | |
format.json { render json: @result } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment