I''m getting this very weird error and I can''t figure out what
the
problem is. I''m using acts_as_commentable. Basically, I have a partial
with this code in it:
<div id="<%= ''#{comment.commentable_type}_comment_#
{comment.commentable_id}'' %>" class="comment">
<dl>
<dt><%= link_to comment.user.login, profile_path(User.find
(comment.user_id).profile) %></dt>
<dd><%= comment.comment %></dd>
</dl>
</div>
and here''s the code that calls the partial:
<% @comments.each do |comment| %>
<%= render :partial => ''partials/comment'', :locals
=> {:comment =>
comment} %>
<% end %>
profile_path(User.find(comment.user_id).profile) is the hack I''ve had
to do to avoid this problem which is weird. All users have a profile,
so they are accessible by user.profile. I get the stack overflow error
when I do comment.user.id, but accessing comment.user.login or any
other attribute works fine. When I do comment.user.profile I get the
NoMethodError. I''ve checked over and over and all associations are in
place....nothing seems wrong to me, yet this error won''t go away. What
could be the problem? :(
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
> > profile_path(User.find(comment.user_id).profile) is the hack I''ve had > to do to avoid this problem which is weird. All users have a profile, > so they are accessible by user.profile. I get the stack overflow error > when I do comment.user.id, but accessing comment.user.login or any > other attribute works fine. When I do comment.user.profile I get the > NoMethodError. I''ve checked over and over and all associations are in > place....nothing seems wrong to me, yet this error won''t go away. What > could be the problem? :(You could start by showing the models that seem to be causing the problem :-) 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
class Comment < ActiveRecord::Base belongs_to :commentable, :polymorphic => true # NOTE: install the acts_as_votable plugin if you # want user to vote on the quality of comments. #acts_as_voteable # NOTE: Comments belong to a user belongs_to :user .... end class Story < ActiveRecord::Base acts_as_commentable acts_as_taggable_on :tags has_many :cores belongs_to :user validates_presence_of :title validates_presence_of :description validates_presence_of :rules validates_length_of :title, :within => 3..50 end class User < ActiveRecord::Base ..... has_many :stories has_many :cores has_many :comments has_one :profile ...... end --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Quoting Mike C <snibble-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> > I''m getting this very weird error and I can''t figure out what the > problem is. I''m using acts_as_commentable. Basically, I have a partial > with this code in it: > > <div id="<%= ''#{comment.commentable_type}_comment_# > {comment.commentable_id}'' %>" class="comment"> > <dl> > <dt><%= link_to comment.user.login, profile_path(User.find > (comment.user_id).profile) %></dt> > <dd><%= comment.comment %></dd> > </dl> > </div> > > and here''s the code that calls the partial: > > <% @comments.each do |comment| %> > <%= render :partial => ''partials/comment'', :locals => {:comment => > comment} %> > <% end %> > > profile_path(User.find(comment.user_id).profile) is the hack I''ve had > to do to avoid this problem which is weird. All users have a profile, > so they are accessible by user.profile. I get the stack overflow error > when I do comment.user.id, but accessing comment.user.login or any > other attribute works fine. When I do comment.user.profile I get the > NoMethodError. I''ve checked over and over and all associations are in > place....nothing seems wrong to me, yet this error won''t go away. What > could be the problem? :(I''ve found model.id problematic. I now always use model[:id] and have had fewer problems, none related to ambiquities around object ID versus record ID, etc. Jeffrey --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks. That fixed that problem...but the other problem still exists. : ( On Jan 2, 5:32 pm, "Jeffrey L. Taylor" <r...-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org> wrote:> Quoting Mike C <snib...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > > > > > > I''m getting this very weird error and I can''t figure out what the > > problem is. I''m using acts_as_commentable. Basically, I have a partial > > with this code in it: > > > <div id="<%= ''#{comment.commentable_type}_comment_# > > {comment.commentable_id}'' %>" class="comment"> > > <dl> > > <dt><%= link_to comment.user.login, profile_path(User.find > > (comment.user_id).profile) %></dt> > > <dd><%= comment.comment %></dd> > > </dl> > > </div> > > > and here''s the code that calls the partial: > > > <% @comments.each do |comment| %> > > <%= render :partial => ''partials/comment'', :locals => {:comment => > > comment} %> > > <% end %> > > > profile_path(User.find(comment.user_id).profile) is the hack I''ve had > > to do to avoid this problem which is weird. All users have a profile, > > so they are accessible by user.profile. I get the stack overflow error > > when I do comment.user.id, but accessing comment.user.login or any > > other attribute works fine. When I do comment.user.profile I get the > > NoMethodError. I''ve checked over and over and all associations are in > > place....nothing seems wrong to me, yet this error won''t go away. What > > could be the problem? :( > > I''ve found model.id problematic. I now always use model[:id] and have had > fewer problems, none related to ambiquities around object ID versus record ID, > etc. > > Jeffrey--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
With the help of a friend, I''ve found what''s causing the error. In the will_paginate plugin under tests/fixtures is a user.rb class defined as class User ActiveRecord::Base. Rails was using that one instead of one in my app/model. My new question is, why was it doing this? It shouldn''t have loaded that one, right? --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---