RAILS_ENV=production doesn't work - ruby-on-rails-4

I put "RAILS_ENV=production" rake about doesn't shows up production info.
deployer#proj:/var/www/proj# RAILS_ENV=production rake about
About your application's environment
Rails version 4.2.0
Ruby version 2.2.1-p85 (x86_64-linux)
RubyGems version 2.4.6
Rack version 1.6.1
JavaScript Runtime Node.js (V8)
Middleware Rack::Sendfile, Rack::Loc.......
Application root /var/www/proj
Environment development
Database adapter mysql2
Database schema version 20150615041442
I even try:
export RAILS_ENV=production
RAILS_ENV=production bundle exec rake db:create
bundle exec rake db:create RAILS_ENV=production

have checked in rails console
like this....
Loading development environment (Rails 4.2.1)
try this
ENV['RAILS_ENV'] ||= 'production' in environment.rb
sudo bundle exec rake db:migrate RAILS_ENV=production
sudo bundle exec rake assets:precompile RAILS_ENV=production
this may help you robmclarty.com
stackoverflow.com/a/27434582/3248148

You could set the environment using bin/rails db:environment:set RAILS_ENV=production and then run your rake tasks.

Related

Having trouble deploying rails application [bundler: failed to load command: rake ] cloudfoundry

I am trying to deploy a rails 6 application using rails buildpack on ibmcloud cloudfoundry but in vain. I get a rake error bundler: failed to load command: rake
https://i.stack.imgur.com/owDQO.png
So after digging around and getting to understand my logs better, I had to update bundle globally for some reason and in due process updated rake. Then I had to create a rake task and put it in the lib folder under task. This automatically gets called in the Rakefile.
After that, in my manifest file, i had inlcuded the command: bundle exec rake cf:on_first_instance db:migrate && bundle exec rails s -p $PORT -e $RAILS_ENV, which now was able to be called while deploying the rails 6 app on cf and run the rake tasks there after.

Redmine agile plugin installation failure - No such file to load -- agile_data

I have Redmine 2 on Ubuntu and want to install additional agile plugin. I have added redmine_agile folder downloaded from http://www.redminecrm.com/projects/agile/pages/1 to /usr/share/redmine/lib/plugins and used commands:
sudo bundle install --without development test
sudo bundle exec rake redmine:plugins NAME=redmine_agile RAILS_ENV=production
After last one, I get:
(in /usr/share/redmine)
rake aborted!
No such file to load -- agile_data
Tasks: TOP => redmine:plugins:migrate => environment
How to solve this problem?
I've unpacked plugin into incorrect folder. It should be unpacked into /usr/share/redmine/plugins. Migration command should be run from /usr/share/redmine/

Rails 4 bundler: command not found: rails

I am guessing that this answer has been already answered somewhere but I was not able to find it. I am having troubles with installing Rails 4. I have put in the Gemfile:
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.1'
And I have run bundle install --path vendor/bundle and all the gems are installed, but when I run bundle exec rails s then I receive an error:
bundler: command not found: rails
Install missing gem executables with `bundle install`
which rails doesn't returning anything. I am using ruby 2.0.0 and rvm and it seems everything has been set up.
What am I missing and how to set-up Rails 4?
What solved my problem for Rails 4, in this case, was running a command in the root directory of the application:
bundle exec rake rails:update:bin
After that , running a bundle exec rails s reported no errors and was working as expected.
In Gemfile please add
ruby 2.0.0
or
Try to use .ruby-version and .ruby-gemset.
Please read this

downgrading rake version from 10.1.1 to 10.1.0

Gemfile
gem 'rails', '4.0.0'
ruby '2.0.0'
I am using rails 4 but some how, rake 10.1.1 is installed. So, whenever I fire a command like
rake db:migrate
It is giving following error:
rake aborted!
You have already activated rake 10.1.1, but your Gemfile requires rake 10.1.0. Using bundle exec may solve this.
I don't want to write bundle exec each time I fire rails commands.
So, any nice solution for this??
Thanks for your interest
Actually,
gem uninstall rake -v 10.1.1
and then
bundle install
Works for me. Thanks Ju Liu.
You could use
gem uninstall rake
and remove the newer version of the gem.
Or add the current version as a binstub with
bundle exec rake rails:update:bin
bundle binstubs rake
After that, you can use
bin/rake db:migrate
Simply run:
bundle update
Done!

Compiling ember-data

In the Read-Me for ember-data I found the following lines:
Getting ember-data:
Currently you must build ember-data.js yourself.
Clone the repository, run bundle then rake dist. You'll find
ember-data.js in the dist directory."
I'm a little confused though... what does "run bundle" mean?
It's a ruby thing. Bundler is a rubygem for managing application dependencies. The bundle command is used to install all of the rubygems that are required by the ember-data project. Try this:
git clone git://github.com/emberjs/data.git
cd data
bundle install
rake
If bundle command is missing, you'll need to install the bundler gem:
gem install bundler
Of course you also need to have a modern version of ruby and rubygems ;-)
See http://gembundler.com/ for more info on bundler
run bundle means install the package dependencies via Bundler which will read the Gemfile and install the dependencies defined in it.
To install the dependencies run the command bundle install