xpepermint
xpepermint

Reputation: 36273

Rails defining methods

I would like to define a method where the first argument is required and the rest are optional. Only first argument must be at first pace.

I try to do this:

my_method(:id, :tags, :user)
my_method(:id, :user, :tags)

def(id, *args)
 ... id...
 ... args[:tags]...
 ... args[:user]...
end

Thank you!

Upvotes: 0

Views: 69

Answers (1)

xpepermint
xpepermint

Reputation: 36273

Found it. I used this code:

def(id, options={})
end

Upvotes: 1

Related Questions