Guest User

Untitled

a guest
Feb 28th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. class SubscriptionsController < ApplicationController
  2. layout "public_framework"
  3. def lander
  4. @company=Company.new(params['company'])
  5. @user=User.new(params['company'].select{|k,v| User.columns.collect{|i| i.name}.include?(k)}.inject({}){|k,v|k.merge(v.first=>v.last)})
  6. @user['email']=params['email'] unless params['email'].nil?
  7. @user['password']=params['password'] unless params['password'].nil?
  8. render :action=>'lander',:layout=>'public_framework'
  9. end
  10. def verify
  11. @company=Company.new(params['company'])#undefined method `'password_confirmation'=' for #<Company:0x47dc428>
  12. if (params['csz'].blank?||params['csz'][/^([a-z A-Z'-]+), ([A-Z]{2}) ([0-9]+)$/].nil?)
  13. @company.errors.add "City, State and ZipCode cannot be empty and must be in the format 'City, ST ZIP' for example: Springfield, MO 65802"
  14. else
  15. @company['city']=params['csz'][/^([a-z A-Z'-]+), ([A-Z]{2}) ([0-9]+)$/,1]
  16. @company['state']=params['csz'][/^([a-z A-Z'-]+), ([A-Z]{2}) ([0-9]+)$/,2]
  17. @company['zip']=params['csz'][/^([a-z A-Z'-]+), ([A-Z]{2}) ([0-9]+)$/,3]
  18. end
  19. if (@company.valid?)
  20. @user=User.new(@company.attributes.select{|k,v| User.columns.collect{|i| i.name}.include?(k)}.inject({}){|k,v|k.merge(v.first=>v.last)}.merge(params['user']))
  21. if (@user.valid?)
  22. @company.save
  23. @user.save
  24. redirect_to :action=>'send_email'
  25. else
  26. render :action=>'lander'
  27. end
  28. else
  29. render :action=>'lander'
  30. end
  31. def send_mail
  32. redirect_to :action=>'waiting_approval','layout'=>'public_framework'
  33. end
  34. def waiting_approval
  35.  
  36. end
  37. end
  38. end
  39. ##model
  40. class User < ActiveRecord::Base
  41. validates_presence_of :email,:address,:phone,:city,:state,:zip
  42. validates_uniqueness_of :email
  43. validates_confirmation_of :password
  44. def self.authenticate(email,password)
  45. @me=find(:first,:conditions=>['email=? and password=md5(?) and activated',email,password])||false
  46. end
  47. end
Add Comment
Please, Sign In to add comment