Class: Admin::ChangesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Admin::ChangesController
- Defined in:
- app/controllers/stenographer/admin/changes_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/stenographer/admin/changes_controller.rb', line 13 def create @change = Change.new(change_params) @change.environments = Rails.env.to_s.downcase if @change.save redirect_to admin_change_path(@change), notice: 'Change Created' else flash.now[:alert] = @change.errors..to_sentence render :new end end |
#destroy ⇒ Object
47 48 49 50 51 52 53 |
# File 'app/controllers/stenographer/admin/changes_controller.rb', line 47 def destroy if @change.destroy redirect_to admin_changes_path, notice: 'Change Destroyed' else redirect_to admin_change_path(@change), alert: @change.errors..to_sentence end end |
#edit ⇒ Object
32 |
# File 'app/controllers/stenographer/admin/changes_controller.rb', line 32 def edit; end |
#index ⇒ Object
25 26 27 28 |
# File 'app/controllers/stenographer/admin/changes_controller.rb', line 25 def index page = params[:page] || 1 @changes = Change.order(created_at: :desc).paginate(page: page, per_page: Stenographer.per_page) end |
#new ⇒ Object
9 10 11 |
# File 'app/controllers/stenographer/admin/changes_controller.rb', line 9 def new @change = Change.new end |
#show ⇒ Object
30 |
# File 'app/controllers/stenographer/admin/changes_controller.rb', line 30 def show; end |
#update ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/stenographer/admin/changes_controller.rb', line 34 def update = {} if @change.update(change_params) [:notice] = 'Change Updated' redirect_to admin_change_path(@change), else flash.now[:alert] = @change.errors..to_sentence render :edit end end |