Module: Gridy::Controller::Actions
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/gridy/controller/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
29 30 31 32 33 34 35 36 37 |
# File 'lib/gridy/controller/actions.rb', line 29 def create self.resource_instance = resource_class.new(resource_params) if resource_instance.save redirect_to resource_instance, notice: "#{resource_name.titleize} was successfully created." else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
47 48 49 50 |
# File 'lib/gridy/controller/actions.rb', line 47 def destroy resource_instance.destroy! redirect_to resource_index_url, notice: "#{resource_name.titleize} was successfully destroyed." end |
#edit ⇒ Object
26 27 |
# File 'lib/gridy/controller/actions.rb', line 26 def edit end |
#index ⇒ Object
14 15 16 17 |
# File 'lib/gridy/controller/actions.rb', line 14 def index gridy_collection(collection, params) render "index" end |
#new ⇒ Object
22 23 24 |
# File 'lib/gridy/controller/actions.rb', line 22 def new self.resource_instance = resource_class.new end |
#show ⇒ Object
19 20 |
# File 'lib/gridy/controller/actions.rb', line 19 def show end |
#update ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/gridy/controller/actions.rb', line 39 def update if resource_instance.update(resource_params) redirect_to resource_instance, notice: "#{resource_name.titleize} was successfully updated." else render :edit, status: :unprocessable_entity end end |