Class: Munificent::Admin::GamesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Munificent::Admin::GamesController
- Defined in:
- app/controllers/munificent/admin/games_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #csv_upload ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
- #upload_csv ⇒ Object
Instance Method Details
#create ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/munificent/admin/games_controller.rb', line 11 def create if @game.save flash[:notice] = "Game created" redirect_to edit_game_path(@game) else flash[:alert] = @game.errors..join(", ") redirect_to new_game_path end end |
#csv_upload ⇒ Object
38 39 40 |
# File 'app/controllers/munificent/admin/games_controller.rb', line 38 def csv_upload :manage, Key end |
#destroy ⇒ Object
33 34 35 36 |
# File 'app/controllers/munificent/admin/games_controller.rb', line 33 def destroy @game.destroy redirect_to games_path end |
#edit ⇒ Object
9 |
# File 'app/controllers/munificent/admin/games_controller.rb', line 9 def edit; end |
#index ⇒ Object
6 |
# File 'app/controllers/munificent/admin/games_controller.rb', line 6 def index; end |
#new ⇒ Object
8 |
# File 'app/controllers/munificent/admin/games_controller.rb', line 8 def new; end |
#show ⇒ Object
7 |
# File 'app/controllers/munificent/admin/games_controller.rb', line 7 def show; end |
#update ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/munificent/admin/games_controller.rb', line 21 def update @game.assign_attributes(game_params) if @game.save flash[:notice] = "Game saved" else flash[:alert] = @game.errors..join(", ") end redirect_to edit_game_path(@game) end |
#upload_csv ⇒ Object
42 43 44 45 46 47 48 |
# File 'app/controllers/munificent/admin/games_controller.rb', line 42 def upload_csv :manage, Key params.fetch(:csv).tempfile.each_line do |code| resource.keys.create(code: code.chomp) end redirect_to games_path end |