Rails: Rails_best_practices - command not found when run on a rails model
I have this line of code:
output = `rails_best_practices /home/jordi/src/adventureManag开发者_StackOverflow中文版er/app`
When I run that in irb, or inside any .rb and I call that .rb from ruby output get some content.
But when I call it inside my model output gets an empty string.
Instead other commands like
output = `cat /home/jordi/src/adventureManager/app/*`
will work everywhere, including inside models I am pretty clueless about this problem
What's rails_best_practices
? is it in your path? My guess is that you got a command not found to stderr when you ran it inside the model.
Or you might try using something like the following from your app root:
output = `bundle exec rails_best_practices /home/jordi/src/adventureManager/app`
Good luck!
I had this same concern when working on a Rails 6 application.
After adding the rails_best_practices gem to my Gemfile
:
group :development, :test do
gem 'rails_best_practices', '~> 1.20'
end
I ran the command below to install it in my application:
bundle install
However, when I ran the command rails_best_practices .
, I get the error below:
rails_best_practices: command not found
Here's how I fixed it:
The issue was that the path of the rails_best_practices executable was not yet available in my current shell/terminal.
I simply closed the current shell/terminal I was on and re-opened a new one.
This time when I ran rails_best_practices .
, it worked fine.
That's all.
I hope this helps
精彩评论