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 45 46 47 48 |
# 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 if @item.try(:fae_redirect_to_form_on_create) redirect_to send("edit_admin_#{@klass_singular}_path", @item.id), notice: t('fae.save_notice') else redirect_to @index_path, notice: t('fae.save_notice') end else build_assets flash[:alert] = t('fae.save_error') render action: 'new' end end |
#destroy ⇒ Object
60 61 62 63 64 65 66 |
# File 'app/controllers/fae/base_controller.rb', line 60 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
68 69 70 71 72 73 74 75 76 |
# File 'app/controllers/fae/base_controller.rb', line 68 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
78 79 80 81 |
# File 'app/controllers/fae/base_controller.rb', line 78 def show # show action is hidden by default, override as needed show_404 end |
#update ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/fae/base_controller.rb', line 50 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 |