Method: Ishapi::GameuiController#do_purchase
- Defined in:
- app/controllers/ishapi/gameui_controller.rb
#do_purchase ⇒ Object
spend the star
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/controllers/ishapi/gameui_controller.rb', line 46 def do_purchase :do_purchase, ::Gameui item = params[:className].constantize.find_by_slug( params[:slug] ) raise 'no such item' if !item raise 'too little funds' if @profile.n_stars < item.premium_tier ::IshModels::UserProfile.with_session do @profile.update_attributes( n_stars: @profile.n_stars - item.premium_tier ) @purchase = ::Gameui::PremiumPurchase.create! user_profile: @profile, item: item end render json: @purchase rescue ::Exception => e render json: e end |