Class: Trestle::Resource::Controller
- Inherits:
-
Admin::Controller
- Object
- ActionController::Base
- ApplicationController
- Admin::Controller
- Trestle::Resource::Controller
- Defined in:
- lib/trestle/resource/controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from Admin::Controller
Instance Method Details
#create ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/trestle/resource/controller.rb', line 12 def create self.instance = admin.build_instance(admin.permitted_params(params)) if admin.save_instance(instance) flash[:message] = ("success.create", default: "The %{model_name} was successfully created.") redirect_to action: :show, id: admin.to_param(instance) else flash.now[:error] = ("failure.create", default: "Please correct the errors below.") render "new" end end |
#destroy ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/trestle/resource/controller.rb', line 45 def destroy self.instance = admin.find_instance(params) if admin.delete_instance(instance) flash[:message] = ("success.destroy", default: "The %{model_name} was successfully deleted.") else flash[:error] = ("failure.destroy", default: "Could not delete %{model_name}.") end redirect_to action: :index end |
#edit ⇒ Object
28 29 30 |
# File 'lib/trestle/resource/controller.rb', line 28 def edit self.instance = admin.find_instance(params) end |
#index ⇒ Object
4 5 6 |
# File 'lib/trestle/resource/controller.rb', line 4 def index self.collection = admin.prepare_collection(params) end |
#new ⇒ Object
8 9 10 |
# File 'lib/trestle/resource/controller.rb', line 8 def new self.instance = admin.build_instance end |
#show ⇒ Object
24 25 26 |
# File 'lib/trestle/resource/controller.rb', line 24 def show self.instance = admin.find_instance(params) end |
#update ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/trestle/resource/controller.rb', line 32 def update self.instance = admin.find_instance(params) admin.update_instance(instance, admin.permitted_params(params)) if admin.save_instance(instance) flash[:message] = ("success.update", default: "The %{model_name} was successfully updated.") redirect_to action: :show, id: admin.to_param(instance) else flash.now[:error] = ("failure.update", default: "Please correct the errors below.") render "show" end end |