【问题标题】:Rails3: conversion of RoR sqlite to postgresql for HerokuRails3:将 RoR sqlite 转换为 Heroku 的 postgresql
【发布时间】:2015-04-03 23:06:35
【问题描述】:

我不熟悉 postgresql,我在本地开发机器上使用 SQLite 运行此代码,但它在使用 postgresql 的生产 Heroku 环境中失败

>  @categories = @user.posts.includes(:category).where(
>          ['`categories`.name = ?', params[:category]])

heroku 日志中的错误:

 ActiveRecord::StatementInvalid (PG::SyntaxError: ERROR:  syntax error at or near "."
2015-02-04T11:38:35.977789+00:00 app[web.1]: LINE 1: ..._id" WHERE ("posts".user_id = 2) AND (`categories`.name = 'm...
2015-02-04T11:38:35.977791+00:00 app[web.1]:                                                              ^

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 sqlite postgresql heroku


    【解决方案1】:

    试试这个@categories = @user.posts.includes(:category).where(:categories => { :name => params[:category]})

    【讨论】:

      【解决方案2】:

      试试:

      @user.posts.includes(:category).where(name: params[:category]])
      

      【讨论】:

        猜你喜欢
        • 2015-09-06
        • 2021-04-02
        • 1970-01-01
        • 2011-10-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-01-31
        • 1970-01-01
        相关资源
        最近更新 更多