Sha256: ead00a6ed947d725adbdafae8a64c88d288be8a7c5e6359c282964ae357f2c8c

Contents?: true

Size: 983 Bytes

Versions: 2

Compression:

Stored size: 983 Bytes

Contents

module ::Phoenix
  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 %> = ::Phoenix::<%= class_name.pluralize %>::<%= 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 %> = ::Phoenix::<%= class_name.pluralize %>::<%= class_name %>.order('position ASC')
    end

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

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
phoenix_core-0.2.1.beta lib/generators/phoenix/extension/templates/app/controllers/phoenix/plural_name_controller.rb
phoenix_core-0.2.0.beta lib/generators/phoenix/extension/templates/app/controllers/phoenix/plural_name_controller.rb