user101289
user101289

Reputation: 10422

rails helper method required parameters

I've read this thread: Rails optional argument and tried to implement it in a Rails 4 helper function that looks like this:

# this is in the application helper
def getRank(team_id, week = '')
  if week.empty?
    week = Settings.pluck(:week) # grab the current week
  end
  # do some stuff to get the current team's rank
end

When I call this in the console however I still get:

> helper.getRank(5)
ArgumentError: wrong number of arguments (1 for 2)
from /home/rails_testing/app/helpers/application_helper.rb:24:in `getRank'

What am I missing?

Upvotes: 0

Views: 438

Answers (2)

shweta
shweta

Reputation: 8169

You must restart your rails console every time you make changes in your code.

You can restart console with this reload! command.

Upvotes: 0

spickermann
spickermann

Reputation: 106972

The rails console reads your application code when it is started. Therefore you need to restart your rails console after changing your code.

Upvotes: 3

Related Questions