Sunday, February 13, 2011

[Rails] Re: Problem with activerecord,a object has no reference

On Feb 14, 6:56 am, Lorenzo Brito Morales <lorenzo.br...@gmail.com>
wrote:
> http://pastie.org/1561681
> Hi i got a problem that object has its fields initialize but no the
> reference to the objects,
> the table has its own id, and has 2 references keys, but i got only
> the fields not the objects
> so i have to query to bring it,
>
> module TodostagsHelper
>
>   def  viewtags(todo_)
>
>     tags =""
>     todo_.todostags.each do |todotag_|
>
>   ##prints ok the todotag_tags_id
>    puts "imprimiendo #{todotag_.tags_id}"
>  ##prints nil to the object todotag_.tag , its suppose to be initialize not?

It should be, but as your code stands it will be using tag_id to find
a Tag object whereas the rest of your code is examining tags_id. What
columns are actually on the table?

Fred
>    puts todotag_.tag
>
>       tip = Tag.find(todotag_.tags_id)
>       tags=  tags.concat(',').concat(tip.name)
>
>     end
>
>     tags
>   end
>
> 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@googlegroups.com.
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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate