On Jun 7, 3:37 am, Jeweller <jiangna...@gmail.com> wrote: > thanks ,Fred. > I still don't understand,because in the model I use the > "validates_presense_of :commenter" to make sure the commenter > won't be nil. > Here's the file I used to generate sample data. > > require 'faker' > def make_comments > Micropost.all.each do |micropost| > User.all(:limit => 2).each do |user| > micropost.comments.create!(:content => > Faker::Lorem.sentence(4), :commenter => user) > end > end > end > > Now, every micropost has two comments, and the commenters are the > first,and the second one in the database. > > In your opinon, what may brings to the situation ---" the path to your > rails app contain some non ASCII characters"
I don't think it's related to the actual problem in your app but I do think it could be triggering a bug in the backtrace cleaner stuff in rails, which is obscuring the actual error you get. Should be easy enough to test this hypothesis Fred > > On 6月7日, 上午2时29分, Frederick Cheung <frederick.che...@gmail.com> wrote: > > > > > On Jun 6, 4:34 pm, Jeweller <jiangna...@gmail.com> wrote: > > > > so I placed this line in the home.html.erb to test > > > <%= @feed_items.first.comments.first.commenter.name %> > > > it's worked! > > > > I'm very confused. I mean what's the difference between these two > > > ways? And also the error message, it's very strange. because I've > > > specified utf-8 encoding in the database.yml > > > Well the main difference is that this is only displaying a single > > name. If for example there is a comment where comment.commenter is nil > > then calling .name on it would raise an error but your second example > > would be ok unless the bad comment happens to be the first comment of > > the first item. > > > I think the actual error message you get is something unrelated > > happening during the process of preparing the error page. Does the > > path to your rails app contain some non ASCII characters perhaps? > > > Fred. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.