Sha256: 5e7f3ba0b571573cfa19dff4c708a23e90db03dbee5110c65c23665aabf4f243

Contents?: true

Size: 1.59 KB

Versions: 6

Compression:

Stored size: 1.59 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

6 entries across 6 versions & 1 rubygems

Version Path
refinerycms-core-2.0.5 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/plural_name_controller.rb
refinerycms-core-2.0.4 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/plural_name_controller.rb
refinerycms-core-2.0.3 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/plural_name_controller.rb
refinerycms-core-2.0.2 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/plural_name_controller.rb
refinerycms-core-2.0.1 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/plural_name_controller.rb
refinerycms-core-2.0.0 lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/plural_name_controller.rb