2014-04-01 28 views
0

我有一个简单的post模型在我的Rails 4应用程序accepts_nested_attributes_for :slide。一切是建立和运行我的开发模式在本地机器上很好,但它抛出这个错误双方的Heroku和数字海洋服务器:Rails 4 has_one/accepts_nested_attributes在本地工作,但不在服务器

app/web.1: ActiveRecord::UnknownAttributeError (unknown attribute: post_id): 
app/web.1: app/controllers/posts_controller.rb:12:in `new' 

这些都是有问题的控制线,上面提到的第12行是第三线下:

def new 
    @post = Post.new 
    @post.build_slide 
end 

我翻了一番检查,并有我的服务器或Heroku的上没有尚未完成迁移无一不是上最新与git的回购协议。本地开发者和远程回购站都在运行postgres。一切都在irb检查:

2.0.0-p247 :001 > a = Post.new 
=> #<Post id: nil, title: nil, en_body: nil, ko_body: nil, short_title: nil, created_at: nil, updated_at: nil, published: nil, slug: nil, ko_title: nil> 
2.0.0-p247 :002 > a.build_slide 
=> #<Slide id: nil, en_title: nil, ko_title: nil, en_description: nil, ko_description: nil, active: false, created_at: nil, updated_at: nil, image_file_name: nil, image_content_type: nil, image_file_size: nil, image_updated_at: nil, link: nil, anchor: nil, post_id: nil> 

为什么服务器可能抱怨未知属性?

+1

请尝试重新启动您的服务器? 我曾经在heroku上发生过一次,我必须在执行迁移后重新启动heroku服务器。 从您的rails应用程序目录中使用'heroku restart'重新启动heroku服务器。 –

+0

欢呼声,那固定的heroku。仍在等待我的服务器重新启动......数字海洋目前似乎遇到了一些问题。 – user2936314

+0

我不知道数字海洋的问题。但是我确定它什么时候启动,您的问题将通过重新启动服务器来解决。 你能否正确地标记我的答案,因为它解决了你的问题? –

回答

0

重新启动你的heroku服务器 它发生在我身上,曾经发生在heroku上, 我必须在执行迁移后重新启动heroku服务器。使用

heroku restart 

从您的Rails应用程序目录 重新启动的Heroku服务器。

相关问题