Forum: Ruby on Rails Quick question about AR arrays.

E67a06cac83a4800368d373c6d704fe9?d=identicon&s=25 Samson Oak (1800dataplz)
on 2014-06-30 23:13
If I have a method "bar" on a model "Foo", this should not work right?

Foo.all.bar

Should be this?

Foo.all.each {|foo| Foo.bar }
E67a06cac83a4800368d373c6d704fe9?d=identicon&s=25 Samson Oak (1800dataplz)
on 2014-06-30 23:14
Oops, I meant Foo.all.each {|foo| foo.bar } for the second one.
A6c7cfa37248fca2135254bc5e776843?d=identicon&s=25 manoj c. (manoj_c)
on 2014-07-02 08:02
Samson Oak wrote in post #1151218:
> Oops, I meant Foo.all.each {|foo| foo.bar } for the second one.

Yes, second one should work as your method is a instance method
Thanks.
Manoj Menon,
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.