Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## model
- class Organization < ActiveRecord::Base
- before_create :create_access_key
- before_save :format_phone_numbers;
- has_many :salaries
- has_many :feedbacks
- has_many :benefitplans
- has_one :user
- def generate_access_key;
- self.access_key = name.crypt("o" + signupip)
- end
- def format_phone_numbers
- contact_areacode = contact_areacode.gsub(/[^\d/, '')
- contact_phone = contact_phone.gsub(/[^\d/, '')
- end
- end
- ##action
- def create #This action is to make the rot13 key to give access to the survey application
- if request.post?
- formdata = params.fetch("organization")
- formdata["signupip"] = request.remote_ip
- begin
- Organization.create(formdata)
- flash[:notice] = "Organization created! Your access key is <strong>#{formdata["access_key"]}</strong>.<br />This key has also been emailed to you at: #{formdata["contact_email"]}</strong>."
- rescue => e
- #handle error... (e.message returns the error in a string)
- flash[:error] = "<strong>There was an error while signing up your organization.</strong><br />Please try again or contact us for assistance."
- end
- else # Show form, etc.
- end
- end
Add Comment
Please, Sign In to add comment