Sha256: 51756d041c4d1c5a8017b4a6ae633ad9046046d23f53e2396bc15b4f9877f20d

Contents?: true

Size: 1.88 KB

Versions: 15

Compression:

Stored size: 1.88 KB

Contents

class Spud::Admin::<%=module_name_formatted.camelize%>Controller < Spud::Admin::ApplicationController
  layout 'spud/admin/detail'
  belongs_to_spud_app :<%=module_name_formatted%>
  before_filter :load_<%=module_name_formatted.singularize%>, :only => [:show, :edit, :update, :destroy]
  add_breadcrumb "<%=module_name_formatted.humanize.titlecase%>", :spud_admin_<%=module_name_formatted%>_path

  def index
    @<%=module_name_formatted%> = <%=module_name_formatted.singularize.camelize%>.paginate :page => params[:page]

    respond_with @<%=module_name_formatted%>
  end

  def new
    @<%=module_name_formatted.singularize%> = <%=module_name_formatted.singularize.camelize%>.new
    respond_with @<%=module_name_formatted.singularize%>
  end

  def create
    @<%=module_name_formatted.singularize%> = <%=module_name_formatted.singularize.camelize%>.create(params[:<%=module_name_formatted.singularize%>])
    respond_with @<%=module_name_formatted.singularize%>, :location => spud_admin_<%=module_name_formatted%>_url
  end

  def edit
    respond_with @<%=module_name_formatted.singularize%>
  end

  def update
    @<%=module_name_formatted.singularize%>.update_attributes(params[:<%=module_name_formatted.singularize%>])
    respond_with @<%=module_name_formatted.singularize%>, :location => spud_admin_<%=module_name_formatted%>_url
  end

  def destroy
    @<%=module_name_formatted.singularize%>.destroy
    respond_with @<%=module_name_formatted.singularize%>, :location => spud_admin_<%=module_name_formatted%>_url
  end

private
  def load_<%=module_name_formatted.singularize%>
    @<%=module_name_formatted.singularize%> = <%=module_name_formatted.singularize.camelize%>.where(:id => params[:id]).first
    if @<%=module_name_formatted.singularize%>.blank?
      flash[:error] = "Whoops, this record does not exist."
      redirect_to spud_admin_<%=module_name_formatted%>_url and return false
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
spud_core-1.0.6 lib/generators/spud/templates/spud_admin_controller.rb.erb
spud_core-1.0.5 lib/generators/spud/templates/spud_admin_controller.rb.erb
spud_core-1.0.4 lib/generators/spud/templates/spud_admin_controller.rb.erb
spud_core-1.0.3 lib/generators/spud/templates/spud_admin_controller.rb.erb
spud_core-1.0.2 lib/generators/spud/templates/spud_admin_controller.rb.erb
spud_core-1.0.1 lib/generators/spud/templates/spud_admin_controller.rb.erb
spud_core-1.0.0 lib/generators/spud/templates/spud_admin_controller.rb.erb
spud_core-1.0.0.rc2 lib/generators/spud/templates/spud_admin_controller.rb.erb
spud_core-1.0.0.rc1.1 lib/generators/spud/templates/spud_admin_controller.rb.erb
spud_core-1.0.0.rc1 lib/generators/spud/templates/spud_admin_controller.rb.erb
spud_core-0.9.22 lib/generators/spud/templates/spud_admin_controller.rb.erb
spud_core-0.9.21 lib/generators/spud/templates/spud_admin_controller.rb.erb
spud_core-0.9.20 lib/generators/spud/templates/spud_admin_controller.rb.erb
spud_core-0.9.19 lib/generators/spud/templates/spud_admin_controller.rb.erb
spud_core-0.9.18 lib/generators/spud/templates/spud_admin_controller.rb.erb