Skip to content

Instantly share code, notes, and snippets.

@santiago
Created November 23, 2010 18:51
Show Gist options
  • Save santiago/712283 to your computer and use it in GitHub Desktop.
Save santiago/712283 to your computer and use it in GitHub Desktop.
def create
@user = User.new(params[:user])
@partner_id= params[:partner_id]
if @user.save
# it should add an activation code
@activation_code= Digest::SHA1.hexdigest(@user.login+Time.now.to_s)
@user.update_attributes({:code => @activation_code})
# it should add birthdate to partner
if params[:year]
date= params[:year]
if params[:month].strip =~ /^\d{2}$/
if params[:day].strip =~ /^\d{2}$/
date << "-#{params[:month]}-#{params[:day]}"
end
end
@user.partner.update_attributes({:birth_date =>date})
end
# it should add gender to partner
if params[:gender]
@user.partner.update_attributes(:gender=>params[:gender])
end
# it should link partners if there is a link request
if @user.partner.has_partner_link_request?
@user.partner.accept_partner_link_request!
end
# context: coming from email link
if params[:c]
# it should receive a valid code
code= EmailCode.find_by_code(params[:c])
# it should link partners
Partner.find(session[:partner_id]).accept_partner_link_request!(code)
# context blind link request
elsif params[:partner]
partner= Partner.find_by_partner_link_code(params[:partner])
begin
# it should link partners
@user.partner.accept_blind_partner_link_request!(params[:partner])
rescue Exception => e
flash[:notice] = e.message
# it should redirect to ""
redirect_back_or_default "/"
return
end
end
tpl= "verify_account"
if params[:client]=="fun"
@redirect_to= "fun_url"
tpl= {:template => "users/fun_verify_account", :layout => false}
end
@user.send_registration_email(params[:client])
respond_to do |format|
format.html { render tpl }
end
else
p "hehehehrhehehe"
render :action => :new
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment