Sha256: 8756195ee79119089339ae20afa0e3ca2739df441695cf7db036ad1702457df8

Contents?: true

Size: 1.07 KB

Versions: 25

Compression:

Stored size: 1.07 KB

Contents

class CalendarController < ApplicationController
  helper_method :get_library, :get_libraries

  def index
    params[:month] ||= Time.zone.now.month
    params[:year] ||= Time.zone.now.year
    @month = params[:month].to_i || Time.zone.now.month
    @year = params[:year].to_i || Time.zone.now.year

    #@shown_month = Date.civil(@year, @month)
    @shown_month = Time.zone.local(@year, @month, 1) rescue Time.zone.now

    # TODO: Solrを使って取得
    if get_library
      @event_strips = Event.at(@library).event_strips_for_month(@shown_month)
    else
      @event_strips = Event.event_strips_for_month(@shown_month)
    end
    get_libraries
  end

  def show
    date = Time.zone.local(params[:year].to_i, params[:month].to_i, params[:day].to_i) rescue Time.zone.now
    date_string = date.strftime('%Y/%m/%d')
    if Event.search do
      with(:start_at).less_than_or_equal_to date
      with(:end_at).greater_than date
    end.results.empty?
      redirect_to new_event_path(:date => date_string)
    else
      redirect_to events_path(:date => date_string)
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
enju_event-0.1.17.pre21 app/controllers/calendar_controller.rb
enju_event-0.1.17.pre20 app/controllers/calendar_controller.rb
enju_event-0.1.17.pre19 app/controllers/calendar_controller.rb
enju_event-0.1.17.pre18 app/controllers/calendar_controller.rb
enju_event-0.1.17.pre17 app/controllers/calendar_controller.rb
enju_event-0.1.17.pre16 app/controllers/calendar_controller.rb
enju_event-0.1.17.pre15 app/controllers/calendar_controller.rb
enju_event-0.1.17.pre14 app/controllers/calendar_controller.rb
enju_event-0.1.17.pre13 app/controllers/calendar_controller.rb
enju_event-0.1.17.pre12 app/controllers/calendar_controller.rb
enju_event-0.1.17.pre11 app/controllers/calendar_controller.rb
enju_event-0.1.17.pre10 app/controllers/calendar_controller.rb
enju_event-0.1.17.pre9 app/controllers/calendar_controller.rb
enju_event-0.1.17.pre8 app/controllers/calendar_controller.rb
enju_event-0.1.17.pre7 app/controllers/calendar_controller.rb
enju_event-0.1.17.pre6 app/controllers/calendar_controller.rb
enju_event-0.1.17.pre5 app/controllers/calendar_controller.rb
enju_event-0.1.17.pre4 app/controllers/calendar_controller.rb
enju_event-0.1.17.pre3 app/controllers/calendar_controller.rb
enju_event-0.1.17.pre2 app/controllers/calendar_controller.rb