【问题标题】:Nested taxon url is no longer working嵌套分类单元 url 不再有效
【发布时间】:2011-02-18 22:03:50
【问题描述】:

这似乎适用于我的本地,但不适用于我的生产。

错误中的数字 4 告诉我它可能返回 nil,因为它对于任何分类单元链接都是 4。

有人知道我可以查看哪些其他

我点击了这个链接:

<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

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-12-08
      • 1970-01-01
      • 2013-12-19
      • 1970-01-01
      • 2015-12-24
      • 1970-01-01
      • 2015-06-27
      相关资源
      最近更新 更多