Skip to content

Instantly share code, notes, and snippets.

@pnegri
Created May 28, 2012 14:59
Show Gist options
  • Save pnegri/2819607 to your computer and use it in GitHub Desktop.
Save pnegri/2819607 to your computer and use it in GitHub Desktop.
Visão de uma App de Notas com IUGU SDK
gem 'iugusdk'
# app/views/my-app/index.html.haml
### PSEUDO
# Links para 'User Profile', 'Logout'
###
FORMULARIO DE ENVIO
###
### foreach @note of @notes
## print @note
# config/initializers/iugusdk.rb
Iugusdk.setup do |config|
# Home page will have just a button, with no forms, no asking for info. Just click "Start Using It"
config.auto_create_guest_user = true
config.app_main_url = '/my-app'
config.default_subscription_name = '1-note'
config.multi_account_users = false
end
# app/controllers/my-app.rb
class MyApp < IuguController::Base
def index
@notes = @current_account.notes.all
end
def save
@total_notes = @current_account.notes.all.count()
if (@total_notes >= @current_account.limits('qtd-notes'))
flash[:error] = "You have reach your plan limit"
flash[:show_upgrade_options = true
redirect_to :action => "index"
end
@note = Note.create( :params[:note] )
@note.save
redirect_to :action => "index"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment