Rails: Is there a way to disable friendly ID in development mode?
-
02-07-2021 - |
문제
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
제휴하지 않습니다 StackOverflow