Module: ExpressAdmin::StandardActions::InstanceMethods
- Defined in:
- lib/express_admin/standard_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
101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/express_admin/standard_actions.rb', line 101 def create build_resource(resource_params) if resource.save respond_to do |format| format.html { redirect_to after_create_path } format.js { render create_view, status: :created } end else respond_to do |format| format.html { render new_view, layout: new_layout } format.js { render create_view, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
146 147 148 149 150 151 152 |
# File 'lib/express_admin/standard_actions.rb', line 146 def destroy load_resource resource.destroy! respond_to do |format| format.html { redirect_to after_destroy_path } end end |
#edit ⇒ Object
124 125 126 127 128 129 |
# File 'lib/express_admin/standard_actions.rb', line 124 def edit load_resource respond_to do |format| format.html { render edit_view, layout: edit_layout } end end |
#index ⇒ Object
86 87 88 89 90 91 92 |
# File 'lib/express_admin/standard_actions.rb', line 86 def index build_resource load_collection respond_to do |format| format.html { render index_view, layout: index_layout } end end |
#new ⇒ Object
94 95 96 97 98 99 |
# File 'lib/express_admin/standard_actions.rb', line 94 def new build_resource respond_to do |format| format.html { render new_view, layout: new_layout } end end |
#show ⇒ Object
116 117 118 119 120 121 122 |
# File 'lib/express_admin/standard_actions.rb', line 116 def show load_resource load_collection respond_to do |format| format.html { render show_view, layout: show_layout } end end |
#update ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/express_admin/standard_actions.rb', line 131 def update load_resource if resource.update_attributes(resource_params) respond_to do |format| format.html { redirect_to after_update_path } format.js { render update_view, status: :ok } end else respond_to do |format| format.html { render edit_view, layout: edit_layout } format.js { render update_view, status: :unprocessable_entity } end end end |