Sha256: faca106aef29a01a3be5f1627b8b8dd3f4ab65c4e282a1903b52ddd026a91937

Contents?: true

Size: 1.57 KB

Versions: 11

Compression:

Stored size: 1.57 KB

Contents

module Refinery
  module <%= namespacing %>
    module Admin
      class <%= class_name.pluralize %>Controller < Refinery::AdminController

        crudify :'refinery/<%= namespacing.underscore %>/<%= singular_name %>', <% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? %>
                :title_attribute => "<%= title.name %>", <% end %>
                :order => "created_at DESC"
<% if @includes_spam -%>

        before_filter :get_spam_count, :only => [:index, :spam]

        def index
          @<%= plural_name %> = find_all_<%= plural_name %>.ham
          @<%= plural_name %> = @<%= plural_name %>.with_query(params[:search]) if searching?

          @grouped_<%= plural_name %> = group_by_date(@<%= plural_name %>)
        end

        def spam
          @<%= plural_name %> = find_all_<%= plural_name %>.spam
          @<%= plural_name %> = @<%= plural_name %>.with_query(params[:search]) if searching?

          @grouped_<%= plural_name %> = group_by_date(@<%= plural_name %>)
        end

        def toggle_spam
          find_<%= singular_name %>
          @<%= singular_name %>.toggle!(:spam)

          redirect_to :back
        end

      protected

        def get_spam_count
          @spam_count = <%= class_name %>.count(:conditions => {:spam => true})
        end
<% else %>
        def index
          unless searching?
            find_all_<%= plural_name %>
          else
            search_all_<%= plural_name %>
          end

          @grouped_<%= plural_name %> = group_by_date(@<%= plural_name %>)
        end

<% end -%>
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
refinerycms-core-2.1.5 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/plural_name_controller.rb.erb
refinerycms-core-2.1.4 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/plural_name_controller.rb.erb
refinerycms-core-2.1.3 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/plural_name_controller.rb.erb
refinerycms-core-2.1.2 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/plural_name_controller.rb.erb
refinerycms-core-2.1.1 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/plural_name_controller.rb.erb
refinerycms-core-2.1.0 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/plural_name_controller.rb.erb
refinerycms-core-2.0.10 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/plural_name_controller.rb.erb
refinerycms-core-2.0.9 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/plural_name_controller.rb.erb
refinerycms-core-2.0.8 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/plural_name_controller.rb.erb
refinerycms-core-2.0.7 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/plural_name_controller.rb.erb
refinerycms-core-2.0.6 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/plural_name_controller.rb.erb