Sha256: b480c7292adb96453ec50322e1c3c2361311eecc02933c2d78503b64caa279d4

Contents?: true

Size: 784 Bytes

Versions: 5

Compression:

Stored size: 784 Bytes

Contents

class <%=module_name_formatted.camelize%>Controller < ApplicationController

  respond_to :html
  before_filter :load_<%=module_name_formatted.singularize%>, :only => [:show]

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

  def show
    respond_with @<%=module_name_formatted%>
  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?
      raise Spud::NotFoundError.new(:item => '<%= module_name_formatted.singularize %>')
      return false
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tb_core-1.2.0 lib/generators/spud/templates/controller.rb.erb
tb_core-1.1.10 lib/generators/spud/templates/controller.rb.erb
tb_core-1.1.9 lib/generators/spud/templates/controller.rb.erb
tb_core-1.1.8 lib/generators/spud/templates/controller.rb.erb
tb_core-1.1.7 lib/generators/spud/templates/controller.rb.erb