0

I'm using meta_search and meta_where gem.In my controller file:

@search = Project.where('end <= ?', Time.zone.now) 
@search = @search.search(params[:search])

When I run this code I have error in browser like this

PG::Error: ERROR:  syntax error at or near "end"
James Fox
  • 27
  • 1
  • 1
  • 4

1 Answers1

0

You may not have an 'end' column on projects, which could mean that you either have a migration and forgot to run it with rake db:migrate, or need to make a migration to add that column. If the column name were end_date, you could do:

rails g migration add_end_date_to_projects end_date:date

Then run the migration.

EDIT: 'end' is a reserved word in PostgreSQL, so I think the column will need to be renamed.

See: http://www.postgresql.org/docs/8.3/static/sql-keywords-appendix.html

Josh Rieken
  • 2,256
  • 1
  • 19
  • 23
  • Ah, 'end' is a reserved word in PostgreSQL, so I think you'll need to rename that column to something else. I'd recommend 'end_date' or 'end_time' as that's more railsy. See also the first answer in http://stackoverflow.com/questions/5570783/using-end-as-column-name-in-ruby-on-rails-mysql – Josh Rieken Jan 12 '13 at 03:29