> On 2015-Sep-4, at 15:56 , Николай Спелый <peavey515...@gmail.com> wrote: > > Great ! > I already try write this logic but it not works. But when i copy-paste your > variant it's work. > So difference is in formating code, i write in one line, you write in three > lines. > That's nice for resolving problem, but why it's works in divided style of > ruby and not works in one-line style ? > My one-line is <%= Chat.find_by(id: 6).chatusers.each { |chat_user| > chat_user.user } %> which about i told.
So you have: <%= something %> which ERB interprets as call .to_s on the result of evaluating something and add that to the output (possibly after making it HTML-safe depending on your Ruby on Rail version) Therefore, what is the value of Chat.find_by(id: 6).chatusers.each { |chat_user| chat_user.user } Well, that's just something.each {|…| … } which has the value of something. In your case, the same as if you just had: Chat.find_by(id: 6).chatusers This is probably some ActiveRecord proxy for the association. The default .to_s is very likely similar to .inspect and looks something like: #<ActiveRecord::… > So plop that into your HTML and a browser sees the <…> as an unknown element and does nothing so you're left with: # in your page. Does that make sense to you? -Rob -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/66CBE3C5-E5B9-46F0-A029-0B9AD6828BBC%40agileconsultingllc.com. For more options, visit https://groups.google.com/d/optout.