Ali
Ali

Reputation: 7493

RSpec giving an error on every action in controller?

this is weird, I'm running bundle exec guard on my rails application and I'm getting a long list of errors for every single action in one solitary container. And all the errors are exactly teh same and make no sense, this is what I'm getting for all the actions:

1) PriceProfilesController GET index assigns all price_profiles as @price_profiles
     Failure/Error: Unable to find matching line from backtrace
     ArgumentError:
       wrong number of arguments (1 for 0)
     # ./app/controllers/price_profiles_controller.rb:15:in `extend'

  2) PriceProfilesController GET show assigns the requested price_profile as @price_profile
     Failure/Error: Unable to find matching line from backtrace
     ArgumentError:
       wrong number of arguments (1 for 0)
     # ./app/controllers/price_profiles_controller.rb:15:in `extend'

... and so forth

Any idea whats going on? The PriceProfileContainer is pretty much a standard scaffold. Where should I be looking at here. The spec files are autogenerated by the scaffold.

UPDATE ----

Here is the Extend function in my controller code:

# GET /price_profiles/1/extend
  def extend
    @price_profile = PriceProfile.find(params[:id])
    @products = Product.all()
    @locations = Location.all()
    @price_profile_date_range = PriceProfileDateRange.new()

    #respond_to do |format|
    #  format.html # extend.html.erb      
    #end
  end

Thats pretty much it.

Upvotes: 0

Views: 439

Answers (1)

Frederick Cheung
Frederick Cheung

Reputation: 84172

extend is a core ruby method that allows you to add a module's methods to an object (sort of like include)

Something (you can probably tell by looking at the remainder of the backtrace) is trying to call extend on an instance of your controller, expecting core ruby's extend method, which takes 1 argument) but is instead finding your extend method which takes no arguments (and of course does something completely different).

The easiest thing would be to pick a different name for your method

Upvotes: 3

Related Questions