Module: RailsStuff::ResourcesController::Actions

Defined in:
lib/rails_stuff/resources_controller/actions.rb

Overview

Basic actions for resources controller.

Instance Method Summary collapse

Instance Method Details

#create(options = {}, &block) ⇒ Object



9
10
11
12
13
14
# File 'lib/rails_stuff/resources_controller/actions.rb', line 9

def create(options = {}, &block)
  if create_resource
    options[:location] ||= after_save_url
  end
  respond_with(resource, options, &block)
end

#destroy(options = {}, &block) ⇒ Object



23
24
25
26
27
28
# File 'lib/rails_stuff/resources_controller/actions.rb', line 23

def destroy(options = {}, &block)
  resource.destroy
  options[:location] ||= after_destroy_url
  flash_errors!
  respond_with(resource, options, &block)
end

#newObject



5
6
7
# File 'lib/rails_stuff/resources_controller/actions.rb', line 5

def new
  build_resource
end

#update(options = {}, &block) ⇒ Object



16
17
18
19
20
21
# File 'lib/rails_stuff/resources_controller/actions.rb', line 16

def update(options = {}, &block)
  if update_resource
    options[:location] ||= after_save_url
  end
  respond_with(resource, options, &block)
end