English 中文(简体)
铁路协会在Heroku失败,但在当地箱子上工作?
原标题:Rails association fails on Heroku but works on local box?

当同一法典在我的地方设置上无节制地运作时,我为什么会把<>NoMethodError带在我的Heroku处?

这一错误是由该法典引起的:

@customer = Customer.find(1)
@customer.responses.create(:offer_id =>  1 , :digit =>  2 )

该法典在我的当地服务器和我的当地铁路网上运行。

然而,在Heroku,上述代码引发NoMethodError:

NoMethodError (undefined method `responses  for #<Customer:0x7f7bcbee3808>):

<>Response模型通过belongs_to :customer模型链接

此外,我可以与Heroku console站在一起,在没有问题的情况下管理:

Response.create(:offer_id =>  1 , :customer_id =>  1 , :digit =>  2 )

因此,如果上述作品和两种版本都在我的当地盒子上进行罚款,那么协会为什么会失败Heroku?

--

铁路3.0.6,在Heroku Duncan 1.8.7和Corr.1。

在Heroku和我的当地箱子上数据库相同。

最佳回答

通常,如果像这种工作那样做,就会发现你再次遗漏了<>s_many的协会。 页: 1 <代码>标签_to和has_many,如果你希望能同时查阅。

凭借其音响,如果它在本地机器上工作,而不是在Heroku公司工作,那就是因为你把改变推向Heroku服务器,并重新启用那里的ole。 请确保你推动变革并再次尝试。

问题回答

马尔科,我认为这是一环,我对你来说有几处gue。 在你完成其中一项任务之前,你将重新主持会议。 有时,这确实是奇迹。

heroku restart

奥克,现在,在奥塞莱角尝试

@customer.responses

这种回报是什么? 我假定应为<代码>[]。 也许会做一些检查,这样会给我们带来深刻的见解。 如果你以人工方式建立并配送答复,你能否看到答复。

其次,你在<代码>responses上没有发现任何方法错误,在<编码>create上,因此,在“BUT”号之后,你的任何类型是:<代码>offer_id和 数字 field integers? 如果是这样,就尝试利用愤怒而不是扼杀手段来制造他们。 与MySQL或Lite相比,PogreSQL非常脆弱,I ve装载的问题追溯到我在Heroku开发之前与Pogre合作的不熟悉。

@customer.responses.create(:offer_id=>1,:digit=>3)

这可能是 t事,但值得检查。

检查的另一点是你的所有呼吁和确认。 是否有任何失败? 这似乎不相关,但我先问,由于在我忽视的警示中似乎无声的失败,事情发生得很满。 我相信你会重新测试,但如果你根据这一模式在任何地方进行 test浅的检测,你也会利用这种unt子来为之带来好处:

关于错误的座谈会,我不知道这是否有助于,但很幸运! 如果Heroku的工作人员发现这一问题,我很有兴趣了解这个问题!

I think you problem is how you are creating the response:

@customer.responses.create(:offer_id =>  1 , :digit =>  2 )

You might want to try this instead.

Response.create(:offer_id =>  1 , :digit =>  2 , :customer_id => 1)




相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签