Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9009857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:18:32+00:00 2026-06-16T02:18:32+00:00

i’m try fullcalendar for my application with rails 3.2 and using postgresql for dbms.

  • 0

i’m try fullcalendar for my application with rails 3.2 and using postgresql for dbms.
to the point,

on model event.rb

class Event < ActiveRecord::Base

  attr_accessible :all_day, :ends_at, :description, :name, :starts_end

  scope :between, lambda {|start_time, end_time|
    {:conditions => ["? < starts_at < ?", Event.format_date(start_time), Event.format_date(end_time)] }
  }

  # need to override the json view to return what full_calendar is expecting.
  # http://arshaw.com/fullcalendar/docs/event_data/Event_Object/
  def as_json(options = {})
    {
      :id => self.id,
      :name => self.name,
      :description=> self.description || "",
      :start => starts_at.rfc822,
      :end => ends_at.rfc822,
      :allDay => self.all_day,
      :recurring => false,
      :url => Rails.application.routes.url_helpers.event_path(id),
      #:color => "red"
    }

  end

  def self.format_date(date_time)
    Time.at(date_time.to_i).to_formatted_s(:db)
  end

end

for starts_at and ends_at i’m using date type (not datetime)

on events.js.coffee

$(document).ready ->
  $('#calendar').fullCalendar
    editable: true,
    header:
      left: 'prev,next today',
      center: 'title',
      right: 'month,agendaWeek,agendaDay'
    defaultView: 'month',
    height: 500,
    slotMinutes: 30,

    eventSources: [{
      url: '/admin'+'/events',
    }],

    timeFormat: 'h:mm t{ - h:mm t} ',
    dragOpacity: "0.5"

    eventDrop: (event, dayDelta, minuteDelta, allDay, revertFunc) ->
      updateEvent(event);

    eventResize: (event, dayDelta, minuteDelta, revertFunc) ->
      updateEvent(event);


updateEvent = (the_event) ->
  $.update "/events/" + the_event.id,
    event:
      name: the_event.name,
      starts_at: "" + the_event.start,
      ends_at: "" + the_event.end,
      description: the_event.description

on controller admin/events_controller.rb

def index
    @events = Event.scoped
    @events = Event.between(params['start'], params['end']) if (params['start'] && params['end'])

    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @events }
    end
  end

First, I insert an event and successfully and when run to localhost:3000/admin/events/ I get the following error such as

      Event Load (14.0ms)  SELECT "events".* FROM "events" WHERE ('2012-11-25 00:00:
    00' < starts_at < '2013-01-06 00:00:00')
    PG::Error: ERROR:  syntax error at or near "<"
    LINE 1: ...events"  WHERE ('2012-11-25 00:00:00' < starts_at < '2013-01...
                                                                 ^
    : SELECT "events".* FROM "events"  WHERE ('2012-11-25 00:00:00' < starts_at < '2
    013-01-06 00:00:00')
    Completed 500 Internal Server Error in 100ms

    ActiveRecord::StatementInvalid (PG::Error: ERROR:  syntax error at or near "<"
    LINE 1: ...events"  WHERE ('2012-11-25 00:00:00' < starts_at < '2013-01...
                                                                 ^
    : SELECT "events".* FROM "events"  WHERE ('2012-11-25 00:00:00' < starts_at < '2
    013-01-06 00:00:00')):

Update

change condition with

{:conditions => [
  "starts_at > ? and starts_at < ?",
  Event.format_date(start_time), Event.format_date(end_time)
] }

and on command promnt

 Event Load (2.0ms)  SELECT "events".* FROM "events" WHERE (starts_at > '2012-1
-25 00:00:00' and starts_at < '2013-01-06 00:00:00')
ompleted 200 OK in 31ms (Views: 15.0ms | ActiveRecord: 12.0ms)

but event not showing in calendar 🙁

Update 2

i’m try example app from
and event display.

Started GET "/events?start=1353776400&end=1357405200&authenticity_token=rTzzn2j+
DpUwKRwjPAdSjfq17glTu8dFjrKo2dGbEo8=&_=1355566671618" for 127.0.0.1 at 2012-12-1
5 17:17:51 +0700
Processing by EventsController#index as JSON
  Parameters: {"start"=>"1353776400", "end"=>"1357405200", "authenticity_token"=
>"rTzzn2j DpUwKRwjPAdSjfq17glTu8dFjrKo2dGbEo8=", "_"=>"1355566671618"}
  ←[1m←[36mEvent Load (1.0ms)←[0m  ←[1mSELECT "events".* FROM "events" WHERE ('2
012-11-25 00:00:00' < starts_at < '2013-01-06 00:00:00')←[0m
Completed 200 OK in 34ms (Views: 31.0ms | ActiveRecord: 1.0ms)

note : resource event

and this my app

Started GET "/admin/events?start=1353776400&end=1357405200&_=135556713595
4" for 127.0.0.1 at 2012-12-15 17:25:36 +0700
Processing by Admin::EventsController#index as JSON
  Parameters: {"start"=>"1353776400", "end"=>"1357405200", "_"=>"1355567135954"}
 Admin Load (2.0ms)  SELECT "public"."admins".* FROM "public"."ad
mins" WHERE "public"."admins"."id" = 25 LIMIT 1
  Account Load (6.0ms)  SELECT "public"."accounts".* FROM "public"."accounts" WH
ERE "public"."accounts"."admin_id" = 25 LIMIT 1
  Event Load (3.0ms)  SELECT "events".* FROM "events" WHERE (starts_at > '2012-1
1-25 00:00:00' and starts_at < '2013-01-06 00:00:00')
Completed 200 OK in 101ms (Views: 72.0ms | ActiveRecord: 24.0ms)

note : resource event under namespace admin ( admin/event ) , and i have multitenant of schema, admin use public schema to login an after login change to other schema (subdomain).

i change type date to datetime

on psql

education_development=# SELECT * FROM subdomain.events WHERE (starts_at > '2
012-11-25 00:00:00' and starts_at < '2013-01-06 00:00:00')
education_development-# ;
 id |     name      |       starts_at        |        ends_at         | all_day
|   description    |         created_at         |         updated_at
----+---------------+------------------------+------------------------+---------
+-----------------+----------------------------+----------------------------
  1 | New Year 2013 | 2013-01-01 00:00:00+07 | 2013-01-01 00:00:00+07 | f
| New Year 2013 | 2012-12-15 06:53:50.695456 | 2012-12-15 06:53:50.695456
(1 row)

Can anyone help me?
thanks 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:18:33+00:00Added an answer on June 16, 2026 at 2:18 am

    You can’t but something like:

    a < starts_at < b
    

    in a WHERE clause, that’s just not valid SQL. You can, however, put:

    starts_at > a AND starts_at < b
    

    You probably want:

    {:conditions => [
      "starts_at > ? and starts_at < ?",
      Event.format_date(start_time), Event.format_date(end_time)
    ] }
    

    BTW, the recommended approach for scopes with arguments is to use a class method:

    Using a class method is the preferred way to accept arguments for scopes.

    So you probably want:

    def self.between(start_time, end_time)
      where('starts_at > :lo and starts_at < :up',
        :lo => Event.format_date(start_time),
        :up => Event.format_date(end_time)
      )
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am using Paperclip to handle profile photo uploads in my app. They upload

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.