Changing gemets to be compatible with Passenger on Dreamhost - ruby-on-rails

I had another post started:
Rack / Passenger fails on Dreamhost
but after some digging I am thinking my gems are incompatible. My Dreamhost Passenger uses Rails 3.0.3 and my dev system has 3.1.3. I have been playing around with rvm and gem but I can't figure out how to force rails and v3.0.3 dependancies.
Can anyone confirm that this is my issue and if so where do I start? I am sure I am missing something obvious but all my Googling has come up empty handed so far.
I am pretty new to Rails and the entire gem concept still hurts my brain and this is probably have the issue I have so far :^)

The simple solution is to edit the passenger entry in your gemfile to this:
gem 'passenger', '3.0.3'
and then run bundle update passenger on your dev machine.
I would really highly recommend you look into using rbenv or rvm to install and manage ruby and gems separate from the system gems that Dreamhost has installed though. I'm not sure if that's outside their terms, but you should be able to install locally for your user. This will help you avoid the same problem with other gems in the future.

Related

Accidentally installed Rails under sudo without RVM. How to move Rails installation and gems to RVM without breaking applications?

So I wish I had known far before that installing Rails with sudo was a bad thing. In fact, after doing my research, it appears that most people would agree that installing any type of package manager as sudo is a big no-no.
Unfortunately for me, I found this out a bit too late. I have several Rails applications that I have created and I am worried that If I try to reinstall Rails with RVM that my applications will not work because of dependency issues.
When I would install gems with bundle install, if the gem was new, Rails would ask for my password before installing it. I did not think much of it at the time, but now, I am worried nothing will work after I try booting a Rails app.
So my questions are:
If I installed Rails with sudo, will my applications still work if I reinstalled it under RVM?
If they don't work, what would I need to make them function correctly?
How do I remove a Rails installation that was installed with sudo?
Is this issue as severe as I think it is?
I had seen a lot of related posts about why one should not use sudo to install gems and Rails in general, as well as why not to do it with RVM, and pretty much not to do it all with anything Ruby related. But I have not seen a post that really addresses any of my concerns and questions that I mentioned above.
No it's not severe as you think. Applications are meant to be portable (somewhat), once you have the same dependencies installed as your development machine, they are meant to work again otherwise you wouldn't be able to deploy.
Now the main thing to check is that all your files in your rails applications are owned by user and not by sudo (otherwise you won't be able to read them later on).
Aside from it, you can simply install rvm, ensure with which ruby and which gem comes from rvm and not from your packaged ruby installation (which you can remove, I do this usually) and then simply run bundle install in your rails application, at that point they are ready to start again.

Offline installation of Rails greater than 2.3.4 gem

I have an intranet only server unable to connect the web even through a proxy, so I always used to update Ruby gems via downloaded gems and the command (e.g for rails):
gem install 'rails-x.y.z.gem'
Now I've got to upgrade rails to, at least, 2.3.11, but can't find that release's gem on RubyForge.
Releases on RF seem to end at 2.3.4...
I guess I'm missing some very basic requirement.
Can someone help me?
Thanks,
Andrea Colleoni
You can find it on rubygems - http://rubygems.org/gems/rails/versions

Installing ferret and acts_as_ferret

I'm looking for a solid walkthrough or some direction on getting ferret set up on my rails server. Everyone on the internet makes it seem so easy, but I can't seem to get it all together.
What I've done succesfully:
gem install ferret
gem install acts_as_ferret
No sweat. No errors.
What doesn't work:
Video.find_by_content('test')
-----No Method Error
or
ActsAsFerret.find('test', 'my_index')
I get console to recognize the constant "ActsAsFerret"(only when I install the plugin from https://github.com/jkraemer/acts_as_ferret), but find() returns a No Method Error.
Update: Installing the plugin like this also prevents Mongrel from starting
I AM running in development mode, but configured ferret_server.yml to know what's up.
So does any one have any suggestions? And has anyone had more luck using acts_as_ferret as a gem or as a plugin? Googling gets me small scraps and parts of tutorials that don't seem to fit together, so I hereby vow to blog a solution to this when I figure it out.
ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]
rails (3.0.3)
P.S. I also ran
sudo apt-get install ferret
on someone's suggestion... still no luck. I'm not even sure if that'd be a reasonable solution for deploying.
have you added
gem 'ferret'
gem 'acts_as_ferret'
in your Gemfile and run
bundle install
?
you can use find_with_ferret method

Passenger with Nginx cannot find rails 2.3.8 gem

I have been trying to setup nginx with passenger for a few days now and keep running into problems. When I go to my Rails application with my browser it says: Missing the Rails 2.3.8 gem. Please gem install -v=2.3.8 rails, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.
If I type gem list in my terminal it shows: rails (3.0.0, 2.3.8, 2.3.5)
What is funny is that passenger will find my ruby gems just fine when I use it with Apache on the same machine! But I would like to experiment with nginx because Apache is not doing what I want.
The machine is Ubuntu 10.04 Server
which ruby Shows: /usr/local/bin/ruby (REE)
These are the passenger directives in the nginx.conf:
passenger_root /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.15;
passenger_ruby /usr/local/bin/ruby;
#Nik Rishav is correct in that you have to be careful when installing Ruby Enterprise Edition (REE) along side the system Ruby. Installing REE incorrectly can cause some very strange things to happen.
While Rails 3.0 could be the cause of your issues, my gut tells me your real issue is one missed step when installing REE. But, just-in-case this doesn't work, a quick Google search will show you any number of good tutorials showing you how to host a Rails app with Phusion Passenger for Nginx. Well, let's give it a go, shall we!
REE runs fine alongside system Ruby, but you have to install it into its own directory. For example:
/opt/ruby-enterprise-X.X.X/bin/ruby
Your other option is to only install REE, but this might not be an option for you. I suspect that when Nginx runs, it does find REE as you have specified it. Did you install Passenger for Nginx from the REE stack?
/opt/ruby-enterprise-X.X.X/bin/passenger-install-apache2-module
If you haven't, you might want to look into that. I'll assume you did.
From your description, it doesn't look like you have told REE where to find your gems. To do this, you need to set REE as the default Ruby Interpreter. To do this, add an entry to the file /etc/environment. On Ubuntu, the directory is /etc/environment. Add REE's bin directory to the PATH environment variable, like this:
PATH="/opt/ruby-enterprise-x.x.x/bin:/usr/local/sbin:/usr/local/bin"
Placing REE first in the PATH will set it as the default Ruby interpreter.
Then restart Nginx, like so:
sudo /etc/init.d/nginx restart
Hopefully this helps. I've had my share of deployment issues and it truly can be frustrating. Wouldn't wish it on anyone...Good luck!
As a check, are you sure your passenger is installed in the correct version of ruby. basically
Both the rubies have separate gems meaning you have to install the other in one..
Check in the /usr/local/lib/ruby/gems/1.8/gems Directory to see if rails 2.3.8 is present. You need to install it in the this ruby.
Both rubies will have separate gem bin files for installation..
possibly /usr/bin/gem is for the system ruby
and /usr/local/bin/gem is for your installation of REE

Paperclip as a gem and Phusion Passenger (mod_rails) - can't find Paperclip

I'm using paperclip by thoughtbot for attachments to models and everything works fine on my development machine running mac os x and mongrel. However when I deploy may app to a debian machine running apache/mod_rails (2.2.5) I can't get it started. I get 'undefined method has_attached_file' (or 'uninitialized constant Paperclip' using an initializer). I'm sure there is an easy solution but I appear to be blind... Any hints? Thanks!
I would suggest just 'vendoring' your gems. Just require the gems you use in your environment.rb file using config.gem syntax (you can search online for more specific instructions) and then once those entries are in there, just run 'rake gems:unpack' and the gems you have installed that are required for the app (via the config.gem entries) will be put in vendor/gems.
This way your app will always know where to find your gems...
Make sure you have this gem properly installed on target machine. If you used REE when installing Passenger then you need to install gems with gem-e instead of gem. In short:
sudo gem-e install paperclip
Blind was right! I finally solved the issue by specifying the paperclip gem thru the proper config.gem entry in environment.rb. I maintain two different environment.rb files, one for development, the other for the production server and I forgot to add the paperclip config.gem line to the latter... Too bad, sorry for bothering you and thanks heaps for answering! Cheers!

Resources