order of records is not proper in heroku
I have a simple test app running on heroku.
But there is an issue in ordering of sub questions.
class Question < A开发者_Python百科ctiveRecord::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
You have to specify the order you expect.
Example:
has_many :sub_questions, :class_name => "Question", :foreign_key=>'parent_id', :order => "id DESC"
精彩评论