嵌套的分类网址已不再有效

时间:2011-02-18 22:03:51

标签: ruby-on-rails taxonomy spree broken-links

这似乎适用于我的本地,但不适用于我的制作。

错误中的数字4告诉我它可能会返回nil,因为任何Taxon链接都是4。

任何人都知道我可以查看 else 的内容吗?

我点击了这个链接:

<a href="/t/shirts/">Shirts</a>

我的错误

ActiveRecord::RecordNotFound (Couldn't find Taxon with ID=4):

我的路线

match '/t/*id' => 'taxons#show', :as => :nested_taxons

#produces this line
nested_taxons   /t/*id(.:format)   {:controller=>"taxons", :action=>"show"}

分类控制器

class TaxonsController < Spree::BaseController
  #prepend_before_filter :reject_unknown_object, :only => [:show]
  before_filter :load_data, :only => :show
  resource_controller
  actions :show
  helper :products

  private
  def load_data
    @taxon ||= object
    params[:taxon] = @taxon.id
    @searcher = Spree::Config.searcher_class.new(params)
    @products = @searcher.retrieve_products
  end

  def object
    @object ||= end_of_association_chain.find_by_permalink(params[:id] + "/")
  end

  def accurate_title
    @taxon ? @taxon.name : nil
  end
end

1 个答案:

答案 0 :(得分:0)

我的数据库中没有永久链接以/结尾。如果您从find_by_permalink电话中删除该结尾斜杠,可能会有一些运气。