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,它應該顯示產品名稱。但事實並非如此。我個人安裝寶石,但沒有效果。
有人可以告訴我缺少什麼嗎?