Is it possible to deploy rails3 and rails4 in the same server? - ruby-on-rails-3

I just want to know if is possible to deploy to passenger a project that I have in rails3 (ruby-1.9.3) and another project in rails4 (ruby-2.0.0). I have installed ruby using RVM on my production server, I'm just wondering if is going to be possible to have 2 different projects on the same production server.
Regards

No problem in that, but there're couple things that you need to do first.
Install nginx instead of Apache and use it with unicorn. You can find a whole lot of setup guides depending on your production server OS, or use the capistrano-nginx-unicorn gem if you use Capistrano for deployment.
Use the rvm-capistrano gem to manage the ruby versions and gemsets used in each project. It's pretty well documented, but if you have further questions, feel free to ask.
If you'll need any further help, you may also consider asking on the freenode#rvm channel. I found some great hints there.

Related

Where's a Gemfile.apk tutorial? Or the default Gemfile.apk gems?

Ruboto rules like no Android development environment has ruled before. It's like the best of Rails combined with the best of the standard Eclipse-Java-Android environment.
Oh, except it's too new & green to even have tutorials or workarounds or even newbie QA in the forums.
For example, I can install Ruboto, and run it, until I try to add a gem to my application. The instructions seem to say to write a Gemfile.apk text file, and put your gem calls in it.
The problems start when I add a gem to that file:
source "http://rubygems.org"
gem 'wrong'
Then the system starts requesting other gems, such as thor, sqlite3, and Rails. Sometimes, it starts complaining about the versions of sdoc and rdoc. That's a story for another post. The upshot is the system asks for gem files one at a time, and expects specific versions.
This leaves me curious where a "master Gemfile.apk" is. So I can get into it, maybe bundle-install it, and I can stop screwing around with versions & mismatches and s--t.
The versions are ruby 1.9 to 2.1.1, and Ruboto 1.0.3.
A long question with many parts :) I'll try to cover all, but feel free to file an issue in the Ruboto tracker or ask on the mailing list or on the IRC channel if you need more info ( http://ruboto.org/community.html ).
You can find tutorials here:
https://github.com/ruboto/ruboto/wiki/Tutorials-and-examples
You can find the FAQ here:
https://github.com/ruboto/ruboto/wiki/FAQ
Tutorials showing use of Gemfile.apk:
https://github.com/ruboto/ruboto/wiki/Tutorial%3A-Using-Bundler
https://github.com/ruboto/ruboto/wiki/Tutorial%3A-Using-an-SQLite-database-with-ActiveRecord
https://github.com/ruboto/ruboto/wiki/Tutorial%3A-write-a-gosu-game
There is no "master Gemfile.apk". Only the gems in the Gemfile.apk and their dependencies should be installed into libs/bundle.jar and included in your app.
I hope this helps you get going. If you see opportunities for improving the documentation, we are open for contributions.

How to organize development of Rails App and multiple Engines

It's hard to formulate the question actually so I just explain the situation.
I'm working on a application that consists of multiple sub applications. The main app just provides an navigation bar and some basic functionality like configuration of users and permissions while the sub applications provide the actual functionalities.
Now this is a Rails 2 application and the sub applications get embedded in frames, it's not really nice design and pretty complex to setup.
Fortunately we have Engines now and that would be the saner solution for this application.
Until now everything lives in subversion and can be updated at once, shared code uses externals. We would like to move to git while we're at restructuring and refactoring.
I've been searching the web the past few days about bundler, git submodules and git subtrees but I haven't found a good description how to properly manage a large project which consists of multiple Engines/Gems when you are developing on all of them the same time.
In particular I would like to be able to:
use Bundler to manage dependencies
do not install our own Gems and Engines into the global gem path but relative to the main app, as an git repository
have our own Gems and Engines setup as git repository (maybe with Bundler's local path override)
an easy way to fetch all dependencies (bundle install) which pulls the latest version of our own Gems and Engines, if that's not possible then one command to git pull all own Gems and Engines (maybe an rake task?)
make it easy for new developers to setup the entire development enviroment fast (git clone the app, bundle install dependencies including all own Gems and Engines, locally)
deploy with Capistrano, easily
What I already thought about:
including everything into one repository, seems to defeat the purpose of separate Gems/Engines for me, also I think it wouldn't allow us to manage the dependencies of the main app on our Engines via Bundler
using submodules, I read too many posts about why it's bad, and with our number of developers it's only a matter of time until somebody commits a submodule pointer to a commit that only exists in his local repo
git subtree utility, seems quite complex to me
So has anybody of you a similar setup and how do you manage it to make updating and committing changes as easy as possible? Where do you put your Engine/Gem code on which the application depends?
TL;DR How do manage a large rails project which consists of multiple Engines and Gems?
We have a similar (but probably less complex) case at my company. What we do (as for now) and that could work for you too :
Put your Rails app in its own git repository. The various gems each get their own repository also (while it is possible to do otherwise, the "one gem = one git repository" will make your life easier).
Then in your Rails app Gemfile, you have several options
Default should be to refer each gem to its git repository (so that bundle will load them from there)
When working locally on some of the gems and the Rails app, either change the Gemfile to use the local path (http://gembundler.com/v1.2/gemfile.html) or better, by overriding the path locally (see: http://gembundler.com/v1.2/git.html). Be careful that those two options are different : the first one use the path, the second the local git repository (so a new uncommitted change will be visible by the first, not by the second).
For updating all your gems easily, I would create a small .sh script (just to launch the various clone or update operations, and the bundle install so that everything comes out clean), and commit it with the main app. I would also get a "standard folder organization" among the team (ie, that everyone use a base folder of their choice, with under it folders for the Rails app and each gem), to make the procedure easier.
I hope this can help or get you ideas (your question is quite complex and manifold, so I'm not 100 % sure this is what you are looking for).
How to manage your Gem dependencies?
Bundler via Gemfile.
How to manage your Engines?
Bundler via Gemfile.
Architect your Engines as Gems and provide their git repo location in your Gemfile. If you want examples, check out how to include the https://github.com/radar/forem gem in your Gemfile.
Also, this helped me learn Rails Engines, http://edgeguides.rubyonrails.org/engines.html.
Are you coming from Java Land?
Rails does have a learning curve, but not like the Java mountain cliff drop off.

Default Gems for Rails (Minimum needed)

I want to clean up my development server. I know there are a ton of gems installed that I do not need. I can't seem to find a list anywhere of the default, or minimum gems that Rails normally installs for its self. If someone can help me out that would be greatly appreciated.
Never mind, I was not going crazy, the gem I had installed became a default in the newest version of rails. I did have a clean environment after all.
If you create a new app, you could pull the gems that it defaults to the Gemfile.

How to deal with different gem dependencies within Bundler for scripts within a single Rails project?

Our Rails application pulls feeds from multiple sources. The workers that pull these feeds need gem dependencies for rmagick, oracle databases, and many other gems. In short, they have very different dependency needs than the main web application. Until Rails 3 and Bundler, life was good.
These worker gem dependencies are irrelevant to our actual production website. Under Rails 3, one Gemfile is expected to contain all these dependencies. This has the nasty side effect of requiring all gem dependencies to be loaded within the production app, which would cause pointless bloat, possible security issues, memory leaks, complicate deployment, and other ills. Sadly, Bundler breaks the standard require mechanism, which would have provided a way out of the quagmire by allowing us to simply require the necessary gems only in the worker and have them somewhere on the system, not in the bundle. The workers use our rails models to file their data.
Can anyone suggest solutions to make the system practical in Rails 3? I am tempted to make the Gemfile use conditional environment variables in places to drive the gem commands, however, it seems the Gemfile.lock could make this problematic going from working on one worker script (for the feeds) to the next, which would have different dependencies. Help???
I've been contemplating a similar problem, and although I don't have a solution in use anywhere yet, your question did make me think it out some more. I think you should be able to use a group to accomplish this. You can add something like this to your Gemfile:
group :workers do
gem "extra_gem_1"
gem "extra_gem_2"
end
Then, you can call
Bundler.require(:default, :workers)
and that should load your gems. How this works will depend on your setup, you might be able to add logic to config/application.rb, or you might need to do this elsewhere. This might be hackish, but it works in the console anyway.
When installing your gems, you can call:
bundle install --without workers
to exclude those gems from production.
Alternatively, you can use two Gemfiles, but that seems like a mess as well since presumably there's some crossover.

Ubuntu Server 64bit 11.04: setting up as "Ruby on Rails" server with SQLite3

I have looked so long for nice tutorials, but still couldn't find any for Ubuntu 11.04. I wan't to set it up to learn by this book: http://ruby.railstutorial.org/ruby-on-rails-tutorial-book
The tutorials I found are not quite up to date and also doesn't aren't for 11.04 Ubuntu.
I am asking for quick tutorial, what's the best way to set up RoR server.
Also if you know any other great Ruby on Rails tutorials, as the link I wrote above, please don't hold back and definitely share the link to it.
Ty in advance!
PS! I already messed up one of my Virtual Machines, but luckily I had made snapshot of clean install.
Ubuntu has Rails packages already. It should be as simple as doing apt-get install rails-ruby1.8, which'll install Ruby as a dependency as well.
Ryan Bigg has a very nice tutorial called Ubuntu, Ruby, RVM, Rails and You. Since you're configuring a server you will probably have a look at some tips about deployment & best practices written by the creator of RVM himself.
I'm sure you have it done already though since it's an old question, but I the links will be of use to someone else.