[英]meta_search with meta_where gem
I'm using meta_search and meta_where gem.In my controller file: 我正在使用meta_search和meta_where gem。在我的控制器文件中:
@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"
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. 您可能在项目上没有“结束”列,这可能意味着您已经进行了迁移,却忘记了使用
rake db:migrate
运行它,或者需要进行迁移以添加该列。 If the column name were end_date, you could do: 如果列名是end_date,则可以执行以下操作:
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. 编辑:“结束”是PostgreSQL中的保留字,因此我认为该列将需要重命名。
See: http://www.postgresql.org/docs/8.3/static/sql-keywords-appendix.html 请参阅: http : //www.postgresql.org/docs/8.3/static/sql-keywords-appendix.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.