Found solution - Use "unloadable" for these classes - http://strd6.com/?p=250

On Jul 20, 11:25 pm, tonymocha <mochat...@gmail.com> wrote:
> Hi,
>
> My system has been encounter this problem, and I couldn't find
> solution after debugging. My scenario is stated below:
>
> class user
>    has_many :posts
>    has_many :comments
> end
>
> class post
>   belongs_to :user
>   has_many :comments, :as => :commentable
> end
>
> class comment
>   belongs_to :post
>   belongs_to :user
> end
>
> For this case, I am trying to retrieve each post's comment together
> with submitter username and I write as below:
>
> class PostsController<ApplicationController
>   def show
>       raise @post.comments.first.user.inspect
>   end
> end
>
> While the first time I run this script, it works fine. But, after I
> hitting a refresh, it hits following problem "can't dup NilClass". It
> is repeats the same for everytime i restart mongrel, working for the
> first time and failed for the rest.
>
> I append the application error log as below:
> /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
> base.rb:2189:in `dup'
> /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
> base.rb:2189:in `scoped_methods'
> /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
> base.rb:2193:in `current_scoped_methods'
> /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
> base.rb:2183:in `scope'
> /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
> base.rb:1548:in `find_every'
> /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
> base.rb:1588:in `find_one'
> /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
> base.rb:1574:in `find_from_ids'
> /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
> base.rb:616:in `find'
> /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
> associations/belongs_to_association.rb:44:in `find_target'
> /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
> associations/association_proxy.rb:240:in `load_target'
> /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
> associations/association_proxy.rb:112:in `reload'
> /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
> associations.rb:1231:in `user'
>
> Need some help for this. Thanks in advance.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to