Module: Adminpanel::RestActions
- Included in:
- ApplicationController
- Defined in:
- app/controllers/concerns/adminpanel/rest_actions.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/concerns/adminpanel/rest_actions.rb', line 24 def create merge_params create! do |success, failure| success.html do flash[:success] = I18n.t('action.save_success') redirect_to resource end failure.html do set_collections render 'shared/new' end success.js do if params[:belongs_request] render 'shared/create_belongs_to', :locals => { :resource => resource } else render 'shared/create_has_many', :locals => { :resource => resource } end end failure.js do set_collections render 'shared/new', :locals => {:resource => resource } end respond_to_json(success, failure) end end |
#destroy ⇒ Object
74 75 76 77 78 |
# File 'app/controllers/concerns/adminpanel/rest_actions.rb', line 74 def destroy destroy! do |format| format.html { render 'shared/index' } end end |
#edit ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'app/controllers/concerns/adminpanel/rest_actions.rb', line 51 def edit edit! do |format| format.html do set_collections render 'shared/edit' end end end |
#index ⇒ Object
4 5 6 7 8 |
# File 'app/controllers/concerns/adminpanel/rest_actions.rb', line 4 def index index! do |format| format.html { render 'shared/index' } end end |
#new ⇒ Object
16 17 18 19 20 21 22 |
# File 'app/controllers/concerns/adminpanel/rest_actions.rb', line 16 def new set_collections new! do |format| format.html { render 'shared/new' } format.js { render 'shared/new', :locals => { :resource => resource }} end end |
#show ⇒ Object
10 11 12 13 14 |
# File 'app/controllers/concerns/adminpanel/rest_actions.rb', line 10 def show show! do |format| format.html { render 'shared/show' } end end |
#update ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/controllers/concerns/adminpanel/rest_actions.rb', line 60 def update update! do |success, failure| success.html do flash.now[:success] = I18n.t('action.save_success') render 'shared/index' end failure.html do set_collections render 'shared/edit' end respond_to_json(success, failure) end end |