Class: Fae::BaseController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Fae::BaseController
- Includes:
- Cloneable
- Defined in:
- app/controllers/fae/base_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #filter ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/fae/base_controller.rb', line 32 def create return create_from_existing(params[:from_existing]) if params[:from_existing].present? @item = @klass.new(item_params) if @item.save redirect_to @index_path, notice: t('fae.save_notice') else build_assets flash[:alert] = t('fae.save_error') render action: 'new' end end |
#destroy ⇒ Object
56 57 58 59 60 61 62 |
# File 'app/controllers/fae/base_controller.rb', line 56 def destroy if @item.destroy redirect_to @index_path, notice: t('fae.delete_notice') else redirect_to @index_path, flash: { error: t('fae.delete_error') } end end |
#edit ⇒ Object
28 29 30 |
# File 'app/controllers/fae/base_controller.rb', line 28 def edit build_assets end |
#filter ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'app/controllers/fae/base_controller.rb', line 64 def filter if use_pagination @items = @klass.filter(params).fae_sort(params).page(params[:page]) else @items = @klass.filter(params).fae_sort(params) end render :index, layout: false end |
#index ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/fae/base_controller.rb', line 11 def index if use_pagination @items = @klass.for_fae_index.page(params[:page]) else @items = @klass.for_fae_index end respond_to do |format| format.html format.csv { send_data @items.to_csv, filename: @items.name.parameterize + "." + Time.now.to_s(:filename) + '.csv' } end end |
#new ⇒ Object
23 24 25 26 |
# File 'app/controllers/fae/base_controller.rb', line 23 def new @item = @klass.new build_assets end |
#show ⇒ Object
74 75 76 77 |
# File 'app/controllers/fae/base_controller.rb', line 74 def show # show action is hidden by default, override as needed show_404 end |
#update ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/fae/base_controller.rb', line 46 def update if @item.update(item_params) redirect_to @index_path, notice: t('fae.save_notice') else build_assets flash[:alert] = t('fae.save_error') render action: 'edit' end end |