Colin Law wrote in post #1071341:
> On 5 August 2012 03:42, Steve Morrissey <[email protected]> wrote:
>
> Since you have not quoted the previous message I have just wasted time
> looking back through the thread to work out what this is about.
> Remember this is a mailing list not a forum, though you may be using a
> forum style interface
>

I do apologize for that, I am quite new to the mailing list format of
communication (which is even harder to grasp while viewing the
discussion on a site called "ruby-forum").
>>
>> comment.user.email yields the commenters email, etc. However when
>> passing comment.user into anything now fails.
>>
>> NoMethodError in Snippets#show
>>
>> Showing
>> /Users/morri534/rails_projects/srclockr/app/views/comments/_comment.html.erb
>> where line #2 raised:
>>
>> undefined method `email' for nil:NilClass
>
> You appear to have provided lots of irrelevant information this time,
> but not shown the code where the error is generated.  I see that it is
> in a partial, and that you are calling email on something that is nil.
>  Perhaps you have forgotten to pass the object to the partial.

This is true, I'm having a very hard time conveying this issue. I have
spent countless hours trying to dig through debugging guides (including
the one referenced by you) yet I haven't been able to ge to the bottom
of this yet. As a direhard PHP programmer, getting my mind into Rails
mode is proving to be a challenge, even after reading a whole book and a
number of web resources on the topic.

So maybe this will help. If anyone is still willing to take a peek, I
have put the code on Github.

The comment form partial that was in place when the comment listings was
working is this:
https://github.com/uberamd/srclockr/blob/93c88fd17bb4ddde6c9a0eb88a87b2cfeefde897/app/views/shared/_comment_form.html.erb

When _comment_form.html.erb looked like that I was able to get comments
to display properly using this code:
https://github.com/uberamd/srclockr/blob/93c88fd17bb4ddde6c9a0eb88a87b2cfeefde897/app/views/comments/_comment.html.erb

However, when I changed _comment_form.html.erb to this code, the ability
to comment started working perfectly, however listing comments stopped
working:
https://github.com/uberamd/srclockr/blob/master/app/views/shared/_comment_form.html.erb

Whats odd (to me) is that I can call comment.user.email and get the
users email, but changing the _comment_form.html.erb file caused the
displaying of comments to break, which is not associated.

The comment, snippet, and user controller can be seen here:
https://github.com/uberamd/srclockr/tree/master/app/controllers

And the page where everything is brought together
(snippets/show.html.erb):
https://github.com/uberamd/srclockr/blob/master/app/views/snippets/show.html.erb

Hopefully this helps clarify the error I'm seeing. Despite my attempts
to debug, I'm just entirely lost as to why changing the partial for the
comment form broke the displaying of comments, though I'm sure its a
fairly basic error I'm encountering. Especially since, on the comments
partial, I'm still able to see the comment.content, just none of the
comment.user (who made the comment) information.

1 beer for anyone who can help guide this lost soul :)

-Steve

>
> Also have a look at the Rails Guide on debugging, which will show you
> techniques that can be used to help in debugging the code.
>
> 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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to