views:

23

answers:

2

Hi, I've defined a function called hash_swap inside the User model, but when I call it it always says Method not found. How could I call a function inside the model ?

A: 

If you're calling a function thats been declared inside the model, WITHIN the model then its straight-forward.

hash_swap 

will call the function. (Ofcourse I'm assuming you don't have any parameters.)

It would be more helpful if you pasted your User model here.

Shreyas Satish
A: 

If you want to call it on the class layer:

Model.hash_swap

you'll have to define the method as class method.

def self.hash_swap
end
rubyphunk