嵌套分类单元 url 不再有效
这似乎适用于我的本地,但不适用于我的作品。
错误中的数字 4 告诉我它可能返回 nil,因为任何 Taxon 链接都是 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"}
Taxons Controller
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
This seems to work on my local, but not on my production.
The number 4 in the error tells me its probably returning nil
as it is 4 for any of the Taxon links.
Anyone know what else I can look into?
I clicked this link :
<a href="/t/shirts/">Shirts</a>
my error
ActiveRecord::RecordNotFound (Couldn't find Taxon with ID=4):
my routes
match '/t/*id' => 'taxons#show', :as => :nested_taxons
#produces this line
nested_taxons /t/*id(.:format) {:controller=>"taxons", :action=>"show"}
Taxons Controller
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的数据库中没有一个永久链接以 / 结尾。如果您从
find_by_permalink
调用中删除尾部斜杠,您可能会运气好。None of the permalinks in my database end with /. You might have some luck if you remove that trailing slash from your
find_by_permalink
call.