with_extension must be defined as class method
def self.with_extension
...
end
On 23 Aug., 11:38, IDK <ulvi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hello, I''m pretty new to ruby and rails.
>
> This is part of my code:
>
> class Command < ActiveRecord::Base
> has_many :executions
>
> def with_extension(ext)
> Extension.all(:include => :command,
> :conditions => { :suffix => ext})
> end
> end
>
> And later in my controller I try to do this:
> @commands = Command.with_extension(''all'')
>
> But I gt an error:
> undefined method `with_extension'' for #<Class:0xb6eaecbc>
>
> That was the first problem, the second is that I''m nut sure how
> the with_extension function should look like.
>
> Here''s my extension schema:
> create_table "extensions", :id => false do |t|
> t.string "suffix"
> t.integer "command_id"
> end
>
> I want to get a list of commands which have a suffix:command mapping.
>
> Niklas Ulvinge
> thanks for your time
> and wishes everyone
> Happy Programming!
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---