Sha256: eb90b8d369fa7e27d4dc78bceecdd356d17b2ba1cfd20ae00536147245d49e14

Contents?: true

Size: 807 Bytes

Versions: 8

Compression:

Stored size: 807 Bytes

Contents

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

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

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

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

private

  def load_<%=module_name_formatted.singularize%>
    @<%=module_name_formatted.singularize%> = <%=module_name_formatted.singularize.camelize%>.find_by(:id => params[:id])
    if @<%=module_name_formatted.singularize%>.blank?
      raise Spud::NotFoundError.new(:item => '<%= module_name_formatted.singularize %>')
      return false
    end
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
tb_core-1.3.2 lib/generators/spud/templates/controller.rb.erb
tb_core-1.3.1 lib/generators/spud/templates/controller.rb.erb
tb_core-1.3.0 lib/generators/spud/templates/controller.rb.erb
tb_core-1.3.0.beta2 lib/generators/spud/templates/controller.rb.erb
tb_core-1.3.0.beta1 lib/generators/spud/templates/controller.rb.erb
tb_core-1.2.8 lib/generators/spud/templates/controller.rb.erb
tb_core-1.2.7 lib/generators/spud/templates/controller.rb.erb
tb_core-1.2.6 lib/generators/spud/templates/controller.rb.erb