Question

I'm using Rails 3.2.7 and Postgres 9.2 trying to create a daterange

Here's how I'm creating it

schedule_block              = ScheduleBlock.new
schedule_block.date_range   = [Date.new, Date.new]
schedule_block.save

And here's the resulting query and the error:

INSERT INTO "schedule_blocks" ("date_range") VALUES ($1) RETURNING "id"  [["date_range", [Mon, 01 Jan -4712, Mon, 01 Jan -4712]]]
PG::Error: ERROR:  malformed range literal: "---
- -4712-01-01
- -4712-01-01
"
DETAIL:  Missing left parenthesis or bracket.
: INSERT INTO "schedule_blocks" ("date_range") VALUES ($1) RETURNING "id"
   (0.1ms)  ROLLBACK
Completed 500 Internal Server Error in 496ms

How can I make this work?

Was it helpful?

Solution

will be available in rails 4 if this pull request will be merged - https://github.com/rails/rails/pull/7345

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top