Class: VouchersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- VouchersController
- Defined in:
- app/controllers/vouchers_controller.rb
Instance Method Summary collapse
- #confirmation ⇒ Object
- #confirmation_error ⇒ Object
- #email_sent ⇒ Object
- #index ⇒ Object
- #print ⇒ Object
- #send_confirmation ⇒ Object
- #show ⇒ Object
Instance Method Details
#confirmation ⇒ Object
12 13 14 |
# File 'app/controllers/vouchers_controller.rb', line 12 def confirmation @user = VoucherUser.new end |
#confirmation_error ⇒ Object
65 66 |
# File 'app/controllers/vouchers_controller.rb', line 65 def confirmation_error end |
#email_sent ⇒ Object
16 17 18 |
# File 'app/controllers/vouchers_controller.rb', line 16 def email_sent @voucher = Voucher.find(params[:id]) end |
#index ⇒ Object
3 4 5 |
# File 'app/controllers/vouchers_controller.rb', line 3 def index @vouchers = Voucher.actives end |
#print ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/vouchers_controller.rb', line 54 def print begin @voucher = Voucher.find(params[:id]) @user = VoucherUser.where(voucher_id: @voucher.id).find(params[:user_id]) render layout: false rescue render :confirmation_error end end |
#send_confirmation ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/vouchers_controller.rb', line 20 def send_confirmation @voucher = Voucher.find(params[:id]) @user = VoucherUser.new(params[:voucher_user]) if @user.already_required(@voucher) if @user.has_confirmed(@voucher) render :show, notice: 'Voce ja requisitou este voucher, por favor, aguardo outra promocao' else render :show, notice: 'Voce ja requisitou este voucher, por favor, acesse seu email para imprimi-lo' end else @voucher.users << @user if @voucher.save redirect_to :vouchers_email_sent else render :show, notice: 'Por favor, corrija os erros abaixo' end end end |
#show ⇒ Object
7 8 9 10 |
# File 'app/controllers/vouchers_controller.rb', line 7 def show @voucher = Voucher.find(params[:id]) @user = VoucherUser.new end |