Class: Lolita::RestController
- Includes:
- ControllerAdditions, Hooks
- Defined in:
- app/controllers/lolita/rest_controller.rb
Instance Method Summary collapse
Methods included from Hooks
Methods included from ControllerAdditions
Instance Method Details
#create ⇒ Object
19 20 21 22 23 24 |
# File 'app/controllers/lolita/rest_controller.rb', line 19 def create self.run(:before_create) .(:create,self.resource_class) build_resource save_and_redirect end |
#destroy ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/lolita/rest_controller.rb', line 44 def destroy self.run(:before_destroy) get_resource .(:destroy, self.resource) if self.resource && self.resource.destroy flash[:notice] = ::I18n.t "lolita.shared.destroy_notice" else flash[:alert] = ::I18n.t "lolita.shared.destroy_alert" end self.run(:after_destroy) redirect_to lolita_resources_path end |
#edit ⇒ Object
26 27 28 29 30 31 |
# File 'app/controllers/lolita/rest_controller.rb', line 26 def edit self.run(:before_edit) get_resource .(:update,self.resource) show_form end |
#index ⇒ Object
57 58 59 60 61 62 |
# File 'app/controllers/lolita/rest_controller.rb', line 57 def index self.run(:before_index) .(:read,self.resource_class) show_index self.run(:after_index) end |
#new ⇒ Object
12 13 14 15 16 17 |
# File 'app/controllers/lolita/rest_controller.rb', line 12 def new self.run(:before_new) .(:create,self.resource_class) build_resource show_form end |
#update ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/lolita/rest_controller.rb', line 33 def update self.run(:before_update) get_resource .(:update,self.resource) if self.resource self.resource=resource_with_attributes(self.resource,resource_attributes) save_and_redirect end end |