Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.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 对象未保存在heroku上,但在本地_Ruby On Rails_Heroku - Fatal编程技术网

Ruby on rails 对象未保存在heroku上,但在本地

Ruby on rails 对象未保存在heroku上,但在本地,ruby-on-rails,heroku,Ruby On Rails,Heroku,一个用户有许多位置。这是身份验证控制器的一部分,该控制器调用LinkedIn供用户进行身份验证: positions.each do |position| @li_pos_id = position.id @title = position.title @company = position.company.name @industry = position.company.industry @start_month = position.start_d

一个用户有许多位置。这是身份验证控制器的一部分,该控制器调用LinkedIn供用户进行身份验证:

positions.each do |position|

    @li_pos_id = position.id
    @title = position.title
    @company = position.company.name
    @industry = position.company.industry
    @start_month = position.start_date.month
    @start_year = position.start_date.year
    @end_month = position.end_date.month
    @end_year = position.end_date.year

    current_user.positions.build(li_pos_id: @li_pos_id, title: @title, company: @company, industry: @industry, 
      start_month: @start_month, start_year: @start_year, end_month: @end_month, end_year: @end_year)
end
我正在绞尽脑汁试图弄明白为什么当前的_user.positions.build(…)会在我的开发(Postgres)数据库中创建一个职位,而不是在Heroku(也是Postgres)上。我的用户对象在身份验证时创建得很好。从我的会话控制器:

def create
      user = User.from_omniauth(env['omniauth.auth'])
      session[:user_id] = user.id
      redirect_to auth_path
    end
从我的用户模型调用以下内容:

def self.from_omniauth(auth)
      where(auth.slice('provider', 'uid')).first || create_from_omniauth(auth)
    end

    def self.create_from_omniauth(auth)
      create! do |user|
        user.provider = auth['provider']
        user.uid = auth['uid']
      end
    end
我的用户模型包含必要的“has\u many:positions”,而我的职位模型包含“belient\u to:user”。无论如何,当前的_user.positions.build(…)行在开发中创建了适当的位置,但在生产中却没有


非常感谢您的帮助!谢谢。

build
不保存记录,它只是生成记录。在第一部分中构建位置之后,您是否将当前用户保存在某个位置?当您说它在本地工作时,您是否使用SQLite作为本地数据库?还是PostgreSQL?如果您在本地使用SQLite,这可能与在dev和prod中使用postgresql是同一个问题,因此SQLite不应该是问题所在。我试图通过将构建设置为positions实例变量并完成auth控制器的position.each循环@positions.save来保存它们,但仍然没有成功!