[Rails] ruby on rails 3, active record, how to address data
Hi to all,
have active record model that has one to many relationship. This is
how it looks like:
ruby-1.9.2-p290 :001 >
@ukuizvj=Izvjestaj.new(:mjesec=>8, :godina=>2011,:djelatnik_id=>2)
=> #<Izvjestaj id: nil, godina: 2011, mjesec: 8, djelatnik_id: 2,
brojsati: nil, visak: nil, manjak: nil, nr: nil, rp: nil, komb: nil,
created_at: nil, updated_at: nil>
ruby-1.9.2-p290 :002 > @ukuizvj.izvjtipd
=> []
ruby-1.9.2-p290 :003 >
ntiprada=Izvjtipd.new(:tipneradni_id=>1, :vrijednost=>1)
=> #<Izvjtipd id: nil, izvjestaj_id: nil, tipneradni_id: 1,
vrijednost: 1, created_at: nil, updated_at: nil>
ruby-1.9.2-p290 :004 > @ukuizvj.izvjtipd << ntiprada
=> [#<Izvjtipd id: nil, izvjestaj_id: nil, tipneradni_id: 1,
vrijednost: 1, created_at: nil, updated_at: nil>]
ruby-1.9.2-p290 :005 > @ukuizvj.izvjtipd
=> [#<Izvjtipd id: nil, izvjestaj_id: nil, tipneradni_id: 1,
vrijednost: 1, created_at: nil, updated_at: nil>]
So, How can I address this value of @ukuizvj.izvjtipd? Problem is that
@ukuizvj.izvjtipd.find_by_tipneradni_id(1).vrijednost or
@ukuizvj.izvjtipd.where(:tipneradni_id=>1).vrijednost dont work until
I make @ukuizvj.save
Thank you
--
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