Skip to content

Instantly share code, notes, and snippets.

@imjacobclark
Created January 22, 2014 21:22
Show Gist options
  • Save imjacobclark/8567581 to your computer and use it in GitHub Desktop.
Save imjacobclark/8567581 to your computer and use it in GitHub Desktop.
def create_user
begin
if self.username.nil? || self.username == 0 || self.password.nil? || self.password == 0 || self.role.nil? || self.role == 0
raise "Missing paramiter"
else
user = User.new(:username => self.username, :password => self.password, :created_at => Time.now, :role => self.role)
if user.save
return true
else
raise "Record not saved"
end
end
rescue Exception => e
return e.message
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment