1
我试图安装宝石FriendlyId。我正在关注railscast:314-pretty-urls-with-friendlyid。它似乎很容易安装。但不为我工作。Rails:FriendlyId宝石不工作
下面是我做的步骤:
added gem "friendly_id", "~> 4.0.9" in Gemfile
然后我跑bundle install
命令
然后修改了产品型号,以这样的:
class Product < ActiveRecord::Base
extend FriendlyId
friendly_id :name
attr_accessible :name, :product_code, :recipe, :selling_price, :servings, letsrate_rateable "quality", "packaging", "hygiene" , "service", "price"
validates :name, :presence => true
class << self
def search(params)
if params[:search]
products = Product.published.includes(:product_sub_categories)
end
end
end
end
不过它显示 'ID':
http://localhost:3000/products/9
根据railscasts,它应该显示产品名称。但事实并非如此。我个人安装宝石,但没有效果。
有人可以告诉我缺少什么吗?