Ruby on Rails Saturday, June 30, 2012

On Sat, Jun 30, 2012 at 4:17 PM, Felipe Pieretti Umpierre
<lists@ruby-forum.com> wrote:

> irb(main):001:0> task = Task.all

Model.all is clearly intended to return multiple results; it would be
more appropriate to say `tasks = Task.all`

> irb(main):002:0> task.project
> NoMethodError: undefined method `project' for #<Array:0x482b068>

in which case you would be calling e.g.

tasks.first.project
or
tasks.each{ |task| puts task.project.inspect }
or whatever

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
twitter: @hassan

--
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-US.

No comments:

Post a Comment