Model methods and joins

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs