简体   繁体   中英

rails 2, why is this controller action returning a nil.to_sym

The following is my show action: def show

    @category = Category.find_by_url_name(params[:id])
          @brands = @category.brands
          @categories = Category.find(:all)
          @meta_title = "#{@category.name}"

    respond_to do |format|
      format.html 
              @brand = @brands.first     
              @search = Product.search.order(params[:order] || 'descend_by_date')

              @products = @search.paginate(:conditions => { :category_id => @category, :brand_id => @brand }, :page => params[:page])      
              render :template => 'brands/show'

      format.xml  { render :xml => @category }
    end
  end

The error its returning:

NoMethodError (You have a nil object when you didn't expect it!
The error occurred while evaluating nil.to_sym):
  searchlogic (2.5.8) lib/searchlogic/active_record/named_scope_tools.rb:16:in `named_scope_options'
  searchlogic (2.5.8) lib/searchlogic/named_scopes/alias_scope.rb:54:in `named_scope_options'
  searchlogic (2.5.8) lib/searchlogic/named_scopes/or_conditions.rb:14:in `named_scope_options'
  searchlogic (2.5.8) lib/searchlogic/search/scopes.rb:15:in `scope_options'
  searchlogic (2.5.8) lib/searchlogic/search/method_missing.rb:80:in `cast_type'
  searchlogic (2.5.8) lib/searchlogic/search/method_missing.rb:22:in `method_missing'
  searchlogic (2.5.8) lib/searchlogic/search/method_missing.rb:36:in `send'
  searchlogic (2.5.8) lib/searchlogic/search/method_missing.rb:36:in `method_missing'
  app/controllers/categories_controller.rb:28:in `show'
  app/controllers/categories_controller.rb:25:in `show'

I have been messing with this for awhile now and its not resolving...

I am using rvm to handle my versioning

gem -v = 1.5.3 Rails -v = 3.1.1 Ruby -v = 1.8.7

I wonder if its the rails version issue... any ideas?

原来是两件事:Rails版本,需要指定2.3.x,是的,在散列中的条件...必须将其设置为数组

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM