문제

I have a rake task to populate my db which depends on faker, so at the top there's:

require 'faker'

The problem is I don't install faker in production so all rake commands (like db:migrate) fail on that require line, saying faker is missing.

Obviously I could install faker in production to get around this, but I don't need it there. So what's the right solution -- can I somehow ignore certain rake tasks in production?

도움이 되었습니까?

해결책

Move the require statement into the task which actually needs it.

다른 팁

I suppose you could just do require 'faker' unless RAILS_ENV='production'

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top