Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/54.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails应用程序在heroku和development上的行为不同_Ruby On Rails_Ruby_Heroku_Pg_Sqlite3 Ruby - Fatal编程技术网

Ruby on rails Rails应用程序在heroku和development上的行为不同

Ruby on rails Rails应用程序在heroku和development上的行为不同,ruby-on-rails,ruby,heroku,pg,sqlite3-ruby,Ruby On Rails,Ruby,Heroku,Pg,Sqlite3 Ruby,在Application Controller中,我有两种方法: def current_user @current_user ||= User.find_by_auth_token( cookies[:auth_token]) if cookies[:auth_token] rescue ActiveRecord::RecordNotFound end helper_method :current_user def pro_user @pro_user = Subscri

在Application Controller中,我有两种方法:

 def current_user
  @current_user ||= User.find_by_auth_token( cookies[:auth_token]) if cookies[:auth_token]
  rescue ActiveRecord::RecordNotFound
 end
 helper_method :current_user

 def pro_user
  @pro_user = Subscription.where(:email => current_user.email).pluck(:email) if current_user
  rescue ActiveRecord::RecordNotFound
end
helper_method :pro_user 
付款完成后,当前用户的电子邮件将插入订阅表。因此,我通过在订阅中查找当前的_user.email来检查该用户是否为付费用户

在视图中,我会相应地阻止专业用户与非专业用户进行此操作

  <% if current_user %>
        <!-- logged in -->      
       <% if pro_user.empty? %>             
               <!-- Not a premium user -->

        <!--Display some html that iss free but not premium content -->

       <% else %> 

            <!-- This is a  premium user  -->
                 <!-- Display all html accordingly -->

       <% end %>     


   <% else %> 
              <!-- Not logged in-->

         <!-- Display html  message to log in -->
   <% end %>     


我的开发机器有SQLITE3DB,一切正常。但在推到heroku时,高级用户从未被认可。基本上我认为如果pro_user.empty?没有按预期工作。感谢您的帮助。empty的返回值是否存在rails差异?sqlite3和pg dbs之间的方法?我做过几次pg:重置

在开发和生产环境中使用不同的数据库肯定存在问题。查询和ORM在sqlite和postgres之间的工作方式可能不同。因此,如果您在heroku上使用实际的本地postgreSQL,我建议您使用它。安装非常简单。只需转到我提供并安装的链接


我想是的。我认为这句话对于博士后来说并没有不同的翻译。订阅。其中(:email=>当前用户。email)。点击(:email)