module Outpost::Controller::Actions

Public Instance Methods

create() click to toggle source
# File lib/outpost/controller/actions.rb, line 29
def create
  @record = model.new(form_params)

  if @record.save
    notice "Saved #{@record.simple_title}"
    respond_with :outpost, @record, location: requested_location
  else
    breadcrumb "New"
    render :new
  end
end
destroy() click to toggle source
# File lib/outpost/controller/actions.rb, line 51
def destroy
  @record.destroy
  notice "Deleted #{@record.simple_title}"
  respond_with :outpost, @record
end
edit() click to toggle source
# File lib/outpost/controller/actions.rb, line 24
def edit
  breadcrumb "Edit", nil, @record.to_title
  respond_with :outpost, @record
end
index() click to toggle source
# File lib/outpost/controller/actions.rb, line 10
def index
  respond_with :outpost, @records
end
new() click to toggle source
# File lib/outpost/controller/actions.rb, line 14
def new
  breadcrumb "New"
  @record = model.new
  respond_with :outpost, @record
end
show() click to toggle source
# File lib/outpost/controller/actions.rb, line 20
def show
  redirect_to @record.admin_edit_path
end
update() click to toggle source
# File lib/outpost/controller/actions.rb, line 41
def update
  if @record.update_attributes(form_params)
    notice "Saved #{@record.simple_title}"
    respond_with :outpost, @record, location: requested_location
  else
    breadcrumb "Edit", nil, @record.to_title
    render :edit
  end
end

Private Instance Methods

form_params() click to toggle source
# File lib/outpost/controller/actions.rb, line 59
def form_params
  params[model.singular_route_key]
end
requested_location() click to toggle source
# File lib/outpost/controller/actions.rb, line 63
def requested_location
  case params[:commit_action]
  when "edit" then @record.admin_edit_path
  when "new"  then model.admin_new_path
  else model.admin_index_path
  end
end