Heroku 中的记录顺序不正确
我有一个简单的测试应用程序在heroku上运行。
但子问题的排序存在问题。
class Question < ActiveRecord::Base
has_many :sub_questions, :class_name => "Question", :foreign_key=>'parent_id'
belongs_to :main_question, :class_name=> "Question", :foreign_key=>'parent_id'
accepts_nested_attributes_for :sub_questions, :allow_destroy => true, :reject_if => lambda { |a| a[:content].blank? }
end
正如您从该页面上的内容中看到的:第一个问题、第二个问题、第三个问题等等。它在数据库中具有相同的 id,这是循环
<% @question.sub_questions.each do |question| %>
// my code....
<% end %>
相同的代码/数据库在我的本地计算机上运行得很好。 这是我的数据库的屏幕截图。 Heroku 有同样的一个。我尝试重新启动应用程序和所有内容。没什么
I have a simple test app running on heroku.
But there is an issue in ordering of sub questions.
class Question < ActiveRecord::Base
has_many :sub_questions, :class_name => "Question", :foreign_key=>'parent_id'
belongs_to :main_question, :class_name=> "Question", :foreign_key=>'parent_id'
accepts_nested_attributes_for :sub_questions, :allow_destroy => true, :reject_if => lambda { |a| a[:content].blank? }
end
As you can see from the content on that page: First question, second question , third question and etc.. It has same id in the data base and here is the loop
<% @question.sub_questions.each do |question| %>
// my code....
<% end %>
The same code/database is working perfectly fine on my local machine.
Here is the screenshot from my database. Heroku has same one. I tried restarting the app and everything. Nothin
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须指定您期望的顺序。
例子:
You have to specify the order you expect.
Example: