Skip to content

Instantly share code, notes, and snippets.

@svisamsetty
Created November 9, 2013 05:02
Show Gist options
  • Save svisamsetty/7381882 to your computer and use it in GitHub Desktop.
Save svisamsetty/7381882 to your computer and use it in GitHub Desktop.
Example of add user
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