Hello Friends ! from my script/console I am getting channel blog feature as below>>Channel.find(:first).blog=> #<Blog id: 1, activated_at: nil, state: true, channel_id: 1, feature_id: 1, created_at: "2009-05-18 13:00:51", updated_at: "2009-05-18 13:00:51"> but i wanted to do something like>>Channel.find(:first)["blog"]=> nil and it should return blog object, but it is not the case... anyone have any idea on this ???? Thanks , Sandip R~ -- Ruby on Rails Developer http://sandip.sosblog.com http://funonrails.wordpress.com www.joshsoftware.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 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 -~----------~----~----~----~------~----~------~--~---
You can only access column attributes this way not, associations. http://railsapi.com/doc/rails-v2.3.2.1/classes/ActiveRecord/Base.html#M001055 Cheers, Nicholas On Jun 19, 9:26 am, Sandip Ransing <san2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello Friends ! > from my script/console > I am getting channel blog feature as below>>Channel.find(:first).blog > > => #<Blog id: 1, activated_at: nil, state: true, channel_id: 1, feature_id: > 1, created_at: "2009-05-18 13:00:51", updated_at: "2009-05-18 13:00:51"> > > but i wanted to do something like > > >>Channel.find(:first)["blog"] > > => nil > and it should return blog object, but it is not the case... > anyone have any idea on this ???? > > Thanks , > > Sandip R~ > > -- > Ruby on Rails Developerhttp://sandip.sosblog.comhttp://funonrails.wordpress.comwww.joshsoftware.com
Solutioneval("hannel.find(:first).#{"blog"}) On Fri, Jun 19, 2009 at 7:31 PM, Nicholas Henry <nicholas.henry-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> > You can only access column attributes this way not, associations. > > > http://railsapi.com/doc/rails-v2.3.2.1/classes/ActiveRecord/Base.html#M001055 > > Cheers, > Nicholas > > On Jun 19, 9:26 am, Sandip Ransing <san2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hello Friends ! > > from my script/console > > I am getting channel blog feature as below>>Channel.find(:first).blog > > > > => #<Blog id: 1, activated_at: nil, state: true, channel_id: 1, > feature_id: > > 1, created_at: "2009-05-18 13:00:51", updated_at: "2009-05-18 13:00:51"> > > > > but i wanted to do something like > > > > >>Channel.find(:first)["blog"] > > > > => nil > > and it should return blog object, but it is not the case... > > anyone have any idea on this ???? > > > > Thanks , > > > > Sandip R~ > > > > -- > > Ruby on Rails Developerhttp://sandip.sosblog.comhttp:// > funonrails.wordpress.comwww.joshsoftware.com > > >-- Ruby on Rails Developer http://sandip.sosblog.com http://funonrails.wordpress.com www.joshsoftware.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 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 -~----------~----~----~----~------~----~------~--~---
On 19 Jun 2009, at 17:08, Sandip Ransing wrote:> Solution > eval("hannel.find(:first).#{"blog"}) >Yuck. send would be much more appropriate here (if you have to) Fred> On Fri, Jun 19, 2009 at 7:31 PM, Nicholas Henry <nicholas.henry-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > wrote: > > You can only access column attributes this way not, associations. > > http://railsapi.com/doc/rails-v2.3.2.1/classes/ActiveRecord/Base.html#M001055 > > Cheers, > Nicholas > > On Jun 19, 9:26 am, Sandip Ransing <san2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hello Friends ! > > from my script/console > > I am getting channel blog feature as > below>>Channel.find(:first).blog > > > > => #<Blog id: 1, activated_at: nil, state: true, channel_id: 1, > feature_id: > > 1, created_at: "2009-05-18 13:00:51", updated_at: "2009-05-18 > 13:00:51"> > > > > but i wanted to do something like > > > > >>Channel.find(:first)["blog"] > > > > => nil > > and it should return blog object, but it is not the case... > > anyone have any idea on this ???? > > > > Thanks , > > > > Sandip R~ > > > > -- > > Ruby on Rails Developerhttp://sandip.sosblog.comhttp:// > funonrails.wordpress.comwww.joshsoftware.com > > > > > -- > Ruby on Rails Developer > http://sandip.sosblog.com > http://funonrails.wordpress.com > www.joshsoftware.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 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 -~----------~----~----~----~------~----~------~--~---