문제

Is there a way to disable friendly ID in development mode?

Thank's!

도움이 되었습니까?

해결책

You can check rails environment in model.

class User < ActiveRecord::Base

  unless Rails.env.development?
    extend FriendlyId
    friendly_id :name, use: :slugged
  end

end

to skip generating new slug in development

class User < ActiveRecord::Base

  extend FriendlyId
  friendly_id :name, use: :slugged

  def should_generate_new_friendly_id?
    false if Rails.env.development?
  end

end

다른 팁

Try to remove this from your Gemfile:

gem 'friendly_id'

and add this on your Gemfile:

group :production, :test do
gem 'friendly_id'
end
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top