# Model methods and joins

**URL:** <https://www.ruby-forum.com/t/model-methods-and-joins/146645>\
**Category:** Rails\
**Created:** [August 23, 2008, 3:53pm UTC](https://www.ruby-forum.com/t/model-methods-and-joins/146645 "2008-08-23T15:53:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![idk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e9a140/32.png) [@idk](https://www.ruby-forum.com/u/idk)\
**Post date:** [August 23, 2008, 3:53pm UTC](https://www.ruby-forum.com/t/model-methods-and-joins/146645/1 "2008-08-23T15:53:54Z")

</div>

Hello, this is a repost, something seemed to go wrong last time I  
tried to post…

Anyway I got this model:  
class Command \< ActiveRecord::Base  
has\_many :executions

def with\_extension(ext)  
Extension.all(:include =\> :command,  
:conditions =\> { :suffix =\> ext})  
end  
end

And this code in a controller method  
@commands = Command.with\_extension(‘txt’)  
But I get this error then  
undefined method `with\_extension’ for #Class:0xb6eaecbc

I’m obviously doing something wrong, but since I’m not very  
experienced with ruby, I don’t know what it is…

Another problem I have is that I’m not sure the method code is right.  
This is the extensions schema:  
create\_table “extensions”, :id =\> false, :force =\> true do |t|  
t.string “suffix”, :null =\> false  
t.integer “command\_id”, :null =\> false  
end

I want to select all commands which is mapped to a specific suffix.
