Skip to content

Commit

Permalink
Merge pull request #10 from vinsol/correct-query-fetch
Browse files Browse the repository at this point in the history
Correct query fetch
  • Loading branch information
bansalakhil committed Jun 26, 2014
2 parents eb9844a + 8c7c14d commit fc0420a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
15 changes: 10 additions & 5 deletions app/controllers/fullcalendar_engine/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@ def new
end
end

def get_events
@events = Event.where('starttime >= :start_time and
endtime <= :end_time',
start_time: Time.at(params['start'].to_i).to_formatted_s(:db),
end_time: Time.at(params['end'].to_i).to_formatted_s(:db))
def index
start_time = Time.at(params[:start].to_i).to_formatted_s(:db)
end_time = Time.at(params[:end].to_i).to_formatted_s(:db)

@events = Event.where('
(starttime >= :start_time and endtime <= :end_time) or
(starttime >= :start_time and endtime > :end_time and starttime <= :end_time) or
(starttime <= :start_time and endtime >= :start_time and endtime <= :end_time) or
(starttime <= :start_time and endtime > :end_time)',
start_time: start_time, end_time: end_time)
events = []
@events.each do |event|
events << { id: event.id,
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
'timeFormat' => "h:mm t{ - h:mm t}"
}
FullcalendarEngine::Configuration.merge!(config)
FullcalendarEngine::Configuration['events'] = "#{FullcalendarEngine::Configuration['mount_path']}/events/get_events"
FullcalendarEngine::Configuration['events'] = "#{FullcalendarEngine::Configuration['mount_path']}/events"
5 changes: 1 addition & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
FullcalendarEngine::Engine.routes.draw do
root :to => 'events#index'
resources :events do
collection do
get :get_events
end
member do
post :move
post :resize
end
end
root :to => 'events#index'
end

0 comments on commit fc0420a

Please sign in to comment.