Rails Ruby Geometry Gem breaking in production - ruby-on-rails

running Geometry::Point.new(1,1) in development goes fine meanwhile in my production server it gives uninitialized constant MyControllerController::Geometry
on my production server, I've checked this:
bundle exec bundle show geometry returns
/path_to_app/shared/bundle/ruby/2.0.0/gems/geometry-6.2
bundle exec bundle show ruby-geometry got
/path_to_app/shared/bundle/ruby/2.0.0/gems/ruby-geometry-0.0.5
in dev , even Point(1,1) works , with no need of module and 'new', which breaks in production too. returning: NameError: uninitialized constant Point
I've tried require 'geometry' and include Geometry, but both till fails
can someone help me plz?

Make sure you you put ruby-geometry gem into your Gemfile like this:
gem 'ruby-geometry', require: 'geometry'
I probably should emphasize it even more in README file of the gem.

After 2 days trying to solve this problem the answer was in reboot the machine... reset only the nginx and unicorn do not worked... but when I do reboot the VPS, it started working ...
How did we find out?
Searching about we have run into Pow not loading gem properly while rails s works
I'm Using Ubuntu with nginx and unicorn, nothing to see with Pow ... whatever it gave some light... for no reason we decided reboot the VPS ... and it worked.
Thank you all who helped me

Related

Deploying Rails App, NameError: uninitialized constant Foundation::Rails::Generators

I'm trying to deploy my first Rails app to my test server. Using Ubuntu, Capistrano, Passenger, Apache. Rails 4.1.9, Ruby 2.0.0.
Everything seems to pull from Github to my production server okay, but rack returns: NameError: uninitialized constant Foundation::Rails::Generators when
try to run rake.
Sorry to be such a N00b but I haven't been able to find the problem.
Error generates from Bundler.require(*Rails.groups) in application.rb
Can anyone point me in the right direction?
Thanks.
Your deployment probably does not run bundle install to install the gems your app needs.
Try adding require 'bundler/capistrano' to the top of your deploy.rb to automatically install the gems in your Gemfile.
Capo.io is a good source when you want to get started with good capistrano recepies btw.

how do I add a gem in heroku?

I updated a gem(rtf) in my ruby on rails app through the Gemfile. The app works fine on my localhost but when I pushed changes to heroku and tried 'bundle install' within heroku bash. I see that the gem has been installed based on the log
Using rtf (0.3.3)
Following this, I did a
heroku restart --a myapp
however, when i tried the app on heroku, it still cant recognize the lib installed through the gem, i get the following error(normally appears when the library cannot be reached for command "require 'RTF'").
cannot load such file -- RTF
What am I doing wrong in heroku?
I think you misunderstand how Heroku works. When you run a bash shell on your app, nothing you do on that dyno will affect any other dynos for your app (like your web dynos). Heroku runs bundle install for you when you deploy your app and if your Gemfile is configured correctly all the gems will be installed.
the answer by sevenseacat is right- i had just got the case wrong-
require 'rtf'
works fine. In OSX, it ignores case in the command require 'RTF'

Rake 10.0.4 not found in sources

I've just pushed a new Rails app from my local development machine to a server I have that has a few Rails apps already on, bundle installs everything correctly and rake tasks run fine, however when I try and start the app it fails with that message.
I've:
Trashed my Gemfile.lock and reran bundle install
Done gem install rake to get the latest version
Checked rake --version shows 10.0.4.
Checked bundle show rake shows 10.0.4
Restarted the server
Now I'm drawing a blank on what it could be. Using Phusion Passenger, rails 3.2.13, ruby 1.9.2p290. I use rvm for managing the environment, but I've not changed anything with it for a long, long while now. The other Rails apps are all working okay without any issues, with similar gem dependencies.
Self fixed, but not sure why. I ran bundle install rake by accident, forgetting it doesn't do what I think and it created a ./rake folder which solved the issue.
Perhaps your application is being run as the wrong user.

Production not finding certain gem methods

I've added added the gem simple-navigation 3.9.0 to my gemfile in rails 3.2.11 and it runs fine in development. However, when I deploy to my production server and try to open a page with the method I get the following error:
undefined method `render_navigation'
I don't believe it's specific to that one gem though, as I had the same problem earlier when I used the uuid gem.
Using $LOADED_FEATURES I find "simple_navigation", so it seems to be loaded.
Info about the production server
nginx 1.2.6
Unicorn 4.5.0
Rubygems 1.8.23
Ubuntu 12.04 LTS
rbenv 0.4.0-9-g045f6c1
EDIT
Other gems work, the server runs fine, except for the above problem.
Make sure your gem is not declared inside the development group in the Gemfile
The gems in the development group are not be loaded in production.
group :development do
gem "simple-navigation"
end
Also, if you have a <APP_HOME>/.bundle/config file, ensure that it doesn't have the BUNDLE_WITHOUT option.
Gemfile
group :ui do
gem "simple-navigation"
end
.bundle/config
---
BUNDLE_WITHOUT: ui
In the above example, the gem group ui will not be loaded.
Having said that I had very-very limited exposure to Rails, I saw similar behavior when Gemfile.lock wasn't committed into repository. As result when project was pushed to production envinronment there was some screw ups with dependency resolution.
Have you try RAILS_ENV=production bundle install ?
While technically not an answer, I decided to switch over to Linode as my host. This involved a complete re-install of my server setup and it's working now. I did the exact same steps installing the server this time as last, so I'm still not sure what was wrong, or if it would have been easily fixable. Since I no longer have the old server available it would be impossible to confirm any solutions proposed from now on.
I'm going to mark this answer as the solution unless there are any objections within the next 48 hours.

RoR app running on mongrel development but not production

This is my first stab at Ruby on Rails. Just deployed a very simple app to Heroku.
The thing is that my app runs flawlessly on mongrel development; When I run it with "mongrel_rails start -e production" however, I get the error "We're sorry, but something went wrong."
For the life of me, I couldn't debug this. Heroku logs is not returning anything, the Exceptional addon in Heroku is not returning anything, and I cannot find mongrel.log on my Windows machine (when I run mongrel using: mongrel_rails start -e production -d"
I'm using Rails 2.3.5 and sqlite3 with bundler to pack my gems.
I was told that probably rails is not booting up correctly. I can't find any other way to diagnose this. Any ideas?
Thanks,
ANaimi
Take a look at your log/production.log file. That should contain detailed information about what's going on. It will usually contain a line that specifies the name of a gem that needs to be installed.
Heroku doesn't use mongrel, so I'm assuming that's what you're trying to do to figure out why it isn't working when you push it to heroku.
I've found, in most cases, my heroku problems have been because of uninstalled gems. Make sure you create a gem manifest.
Try tailing logs while booting up. From the terminal in the log directory do: tail -f *.log and then launch the app from another terminal (likely it's development.log since you're probably running in development mode.)
Not sure if this got definitively answered, however, check your '%app_root%/config/environments/' folder, and compare 'development.rb' to 'production.rb'.
Make sure that you have all necessary settings in the production.rb file - might have missed something important there.

Resources