Skip to content

Instantly share code, notes, and snippets.

@ashga
Created July 3, 2012 11:43
Show Gist options
  • Save ashga/3039252 to your computer and use it in GitHub Desktop.
Save ashga/3039252 to your computer and use it in GitHub Desktop.
user gets logged out.
class Spree::RewardsRegistrationController < ApplicationController
def index
if !current_user
redirect_to spree.login_path
else
#render :text => "TEST ID"
user = Spree::User.find(Spree::User.current.id)
user.rewards ? @filled = true : @filled = false
end
end
def create
new_reg = Spree::RewardsRegistration.new(params[:rewards_registration])
new_reg.save!
user = Spree::User.find(new_reg.user_id)
user.rewards = true
user.save!
rp = Spree::RewardsPoint.new(:awarded => 250, :used => 0, :user_id => new_reg.user_id)
rp.save!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment