Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SubscriptionsController < ApplicationController
- layout "public_framework"
- def lander
- @company=Company.new(params['company'])
- @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)})
- @user['email']=params['email'] unless params['email'].nil?
- @user['password']=params['password'] unless params['password'].nil?
- render :action=>'lander',:layout=>'public_framework'
- end
- def verify
- @company=Company.new(params['company'])#undefined method `'password_confirmation'=' for #<Company:0x47dc428>
- if (params['csz'].blank?||params['csz'][/^([a-z A-Z'-]+), ([A-Z]{2}) ([0-9]+)$/].nil?)
- @company.errors.add "City, State and ZipCode cannot be empty and must be in the format 'City, ST ZIP' for example: Springfield, MO 65802"
- else
- @company['city']=params['csz'][/^([a-z A-Z'-]+), ([A-Z]{2}) ([0-9]+)$/,1]
- @company['state']=params['csz'][/^([a-z A-Z'-]+), ([A-Z]{2}) ([0-9]+)$/,2]
- @company['zip']=params['csz'][/^([a-z A-Z'-]+), ([A-Z]{2}) ([0-9]+)$/,3]
- end
- if (@company.valid?)
- @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']))
- if (@user.valid?)
- @company.save
- @user.save
- redirect_to :action=>'send_email'
- else
- render :action=>'lander'
- end
- else
- render :action=>'lander'
- end
- def send_mail
- redirect_to :action=>'waiting_approval','layout'=>'public_framework'
- end
- def waiting_approval
- end
- end
- end
- ##model
- class User < ActiveRecord::Base
- validates_presence_of :email,:address,:phone,:city,:state,:zip
- validates_uniqueness_of :email
- validates_confirmation_of :password
- def self.authenticate(email,password)
- @me=find(:first,:conditions=>['email=? and password=md5(?) and activated',email,password])||false
- end
- end
Add Comment
Please, Sign In to add comment