Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
eventful / lib / eventful / core_ext / active_admin.rb
Size: Mime:
module Eventful
  module CoreExt
    module ActiveAdmin
      module ResourceDSL
        def eventful_activeadmin
          config.sort_order = 'start_at_asc'
          actions :all, :except => :show

          scope :all, :default => true
          scope :current
          scope :upcoming
          scope :past

          index do
            column :title
            column :start_at

            default_actions
          end

          form :partial => 'admin/events/form'

          controller do
            def new
              start_time = DateTime.now.advance(:hours => 1).beginning_of_hour
              end_time   = start_time.advance(:hours => 1)

              instance_variable_set("@#{resource_class.name.underscore}",
                                     resource_class.new(:start_at => start_time,
                                                        :end_at   => end_time))
            end
          end
        end
      end
    end
  end
end