on-the-way on-the-way - 1 year ago 51
Ruby Question

How to pass parameter in rails method?

I have the following method that returns true or false:

def my_method?
# do stuff here

The question is, can I pass parameter with above method? How can I achieve this thanks!

I do like this but it won't work:

def my_method?(params)
# do stuff


def my_method?(params)`

will create an instance method, which thus must be called on an instance of your User class eg


(as per the other comment)

If you want to be able to call it on your User class itself, then you must define it as a class method eg:

def self.my_method?(params)