Sha256: df55a2a41852aea37a72b360d9ecedc491a447d96185a76cc69094bc51a8809c

Contents?: true

Size: 979 Bytes

Versions: 2

Compression:

Stored size: 979 Bytes

Contents

module Answers
  module <%= namespacing %>
    class <%= class_name.pluralize %>Controller < ::ApplicationController

      before_filter :find_all_<%= plural_name %>
      before_filter :find_page

      def index
        # you can use meta fields from your model instead (e.g. browser_title)
        # by swapping @page for @<%= singular_name %> in the line below:
        present(@page)
      end

      def show
        @<%= singular_name %> = <%= class_name %>.find(params[:id])

        # you can use meta fields from your model instead (e.g. browser_title)
        # by swapping @page for @<%= singular_name %> in the line below:
        present(@page)
      end

    protected

      def find_all_<%= plural_name %>
        @<%= "all_" if plural_name == singular_name %><%= plural_name %> = <%= class_name %>.order('position ASC')
      end

      def find_page
        @page = ::Answers::Page.where(:link_url => "/<%= plural_name %>").first
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
answers-core-0.0.0.2 lib/generators/answers/engine/templates/app/controllers/answers/namespace/plural_name_controller.rb.erb
answers-core-0.0.0 lib/generators/answers/engine/templates/app/controllers/answers/namespace/plural_name_controller.rb.erb