dennismonsewicz
dennismonsewicz

Reputation: 25542

Rails 3: Pass options to model method

This is my Model (Subscription) Method:

  def activation_codes(options = {})
    if options[:first]
      self.group.group_codes.first
    else
      self.group.group_codes
    end
  end

I am trying to call to this method in this fashion:

sub = Subscription.where(:subscription_limit => -1).first
sub.activation_codes {:first}

For some reason the elseis being evaluated.

Upvotes: 0

Views: 73

Answers (1)

NARKOZ
NARKOZ

Reputation: 27901

You need to pass Hash to method activation_codes in order to make it work as expected, like:

sub.activation_codes({:first => 'some value'})

but you're currently passing Symbol instead.

Upvotes: 1

Related Questions