# Need clarification

**URL:** <https://www.ruby-forum.com/t/need-clarification/191274>\
**Category:** Rails\
**Created:** [July 8, 2010, 6:13pm UTC](https://www.ruby-forum.com/t/need-clarification/191274 "2010-07-08T18:13:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomtt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@tomtt](https://www.ruby-forum.com/u/tomtt)\
**Post date:** [July 8, 2010, 6:13pm UTC](https://www.ruby-forum.com/t/need-clarification/191274/1 "2010-07-08T18:13:11Z")

</div>

hi

i have a Project & Task model.

########  
Project model has that additional method:

def self.lasttask(project, sort=“DESC”)  
Task.find(:first, :conditions=\>['project\_id = ? ',  
project.id], :order =\> “somedate #{sort}” )  
end

########  
The Task model has one attribute called “specialtask” which is  
boolean.  
bewteen  
Now, i can do this in the console:  
p=Project.find(1)  
Project.lasttask§.specialtask

> > TRUE or FALSE

meaning its working. But doing it in the view it throws me an error  
telling me specialtask is unknown.  
\<%= debug Project.lasttask§.specialtask %\>

//the debug shows cleary the attribute.

so, where is my error here? any pointers are welcome.  
sidenote: i know i could do this wich “nromal” associations too, but  
im in the process of learning the innnerworkings of ruby classes (self  
or not self)

thx

---

<div class="post-metadata">

**Author:** ![tomtt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@tomtt](https://www.ruby-forum.com/u/tomtt)\
**Post date:** [July 8, 2010, 7:39pm UTC](https://www.ruby-forum.com/t/need-clarification/191274/2 "2010-07-08T19:39:51Z")

</div>

On 8 July 2010 17:12, tom [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> project.id], :order =\> “somedate #{sort}” )  
> end

As a side note this would be better as a named\_scope.

> meaning its working. But doing it in the view it throws me an error  
> telling me specialtask is unknown.  
> \<%= debug Project.lasttask(p).specialtask %\>
> 
> //the debug shows cleary the attribute.

I don’t understand, first you say it throws an error, then you say it  
clearly shows the attribute.  
Can you post the code around the error and the exact error and stack  
dump please?

Colin
