Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct query fetch #10

Merged
merged 2 commits into from
Jun 26, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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