友好的ID和Rails引擎

时间:2014-04-09 01:48:03

标签: ruby-on-rails rails-engines friendly-id

我按照步骤让rails_id在rails引擎中工作 - 发布here on github,当我执行以下操作时似乎:

  s.add_dependency 'friendly_id', '~> 5.0.0'

在engine.gemspec文件中然后执行:

bundle install #=> works
rails g friendly_id #=> works
rake db:migrate

我明白了:

rake aborted!
uninitialized constant FriendlyId
嗯......什么?

更新 - 使用FriendlyId的模态

  module Xaaron
     class Role < ActiveRecord::Base
        extend FriendlyId
        friendly_id :role, use: :slugged

        validates :role, presence: true
        validates_uniqueness_of :role
      end
   end

1 个答案:

答案 0 :(得分:6)

您可能需要明确要求引擎中的FriendlyId(docs):

require 'friendly_id'