On 2 March 2016 at 22:06, David Williams <lists@ruby-forum.com> wrote:
> Colin Law wrote in post #1181852:
>> On 2 March 2016 at 21:43, David Williams <lists@ruby-forum.com> wrote:
>>> Iterating over the @following_activities instance variable is giving me
>>> errors for user.avatar.url and user.post. I don't understand why it's
>>> not collecting all of the information from the user object.
>>>
>>> <% if @following_activities.any? %>
>>> <% @following_activities.each do |user| %>
>>
>> In the code you posted earlier the activities are Post objects not
>> User objects. Possibly you want
>> @following_activities.each do |post|
>> and then post.user.photo.... etc
>>
>> Colin
>
> It's working now. Thank you and Mahcsig for helping me.
Just to point out that the fundamental mistake you made here was
calling it @following_activities. If you had called it
@following_posts or something similar then you would probably fnot
have made the error.
For the future simple debugging can be achieved by inserting logger
output in the code at appropriate points, so for example if after the
line
<% @following_activities.each do |user| %>
you insert the line
logger.info "user = #{user.inspect}"
then the debug would be inserted into log/development.log which would
probably have enabled you to see the problem.
Colin
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> 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+unsubscribe@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/7519ae9bd5b199cf223e513ad94674b4%40ruby-forum.com.
> For more options, visit https://groups.google.com/d/optout.
--
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+unsubscribe@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/CAL%3D0gLsvoS7f%2BcJm4qTK5mn_sfCmBw3_v7DiVZ2tPrYuG4gYeg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment