How to manange projects that doesn't have gem file? - ruby-on-rails

Under Rails 2 projects doesn't have the gemfile.
In this case which is the best way to manage the gems?, which gems should I vendor? also I will like to know if there's another way to manage this?

You can manage gem using bundle in rails 2.3 app ,you can refer
http://gembundler.com/rails23.html
http://yehudakatz.com/2009/11/03/using-the-new-gem-bundler-today/

Related

Is it possible to create a ruby gem that when added to a rails project simply appends code to its initializers?

I've got some helper code (monkey patches) I tend to carry around from rails project to rails project via simply copying files or pasting code into the initializers folder.
I think a clean way to deploy different categories of my initalizer code would be to simply add gems to my project Gemfile that would do the equivalent of this for me. I'm not very skilled at creating gems or the deeper side of ruby on rails engineering so I just wanted to know if this were possible before I got started with it.
Yes, this is definitely possible. It should be probably enough to make a simple gem, put your monkey-patches there and require them in the gem entry point (e.g., if the gem is called foobar, then bundler will require lib/foobar.rb by default).
There is a guide on creating gems available in Bundler docs. In case you need to interact with Rails application configuration, you can take a look at Rails Engines.

Rails 3: Using a gem as my main app

I want to use the code of a gem as my main application code instead of just installing it with "bundle install".
How can I create an entire rails app based on a gem and using that gem as my app?
Thank you.
You are looking for Rails Engines instead I believe. If not, then can you explain your problem further?

How to develop Gems?

I would like to write my own gem that helps me in my rails apps. It will also inculde some controllers that deliver html. So i need to test that in a browser (html/css/js).
Whats the best practice for that?
Now im using the echoe gem to build my gem (are there any better gems?).
rake install
switch to other tab
stop the rails app
start the rails app (so it has loaded the gem)
and then testing it, in a browser with good old refresh.
This is no fun. Can i do it more efficient somehow? Is it insane not to write tests for the ruby files?
You could use two resources to help you:
https://github.com/krschacht/rails_3_engine_demo
https://github.com/josevalim/enginex
This will help you creating a gem which will basically be an engine (enabling controller and views). The first link as great and helpful documentation.
The main principle is to code in a separate folder and add your 'gem' in local by doing gem ‘cheese’, :path => "../rails_3_engine_demo"
Once you feel ready, pack it with jeweller or bundler. Here is another link: http://sirupsen.com/create-your-first-ruby-gem-and-release-it-to-gemcutter//
Including the gem this way in your app will enable you to properly test it's behaviour.
jeweler:Opinionated tool for creating and managing Rubygem projects

In Rails, how to update plugins used in an application?

If I use devise, or any other plugin for that matter, what are the best practises for updating it when its in my rails 3 app?
I know devise allows you to modify things, how will this work?
in rails 3 you should most likely be managing everything through your Gemfile and bundler. You would update and maintain your gems through bundler. http://gembundler.com/

what is the best to use - ruby gems or ruby plugins

What is the best practice when creating a rails project
1 - is it good to use ruby gems
2 - or is it good to use ruby plugins (as almost all the gems has their plugin versions)
and what are the strengths and weaknesses of eachoption
consider we are creating the rails project with rails 2.x.x or rails 3
thanks in advance
cheers,
sameera
I think you should have to go with gems if possible. You will have a rich framework with slim applications. If you use a lot of plugins your application will be too heavy. I'm talking from experience. I have an application with a lot of plugins in it and it is hell slow.
I prefer to use gems because then I can manage them with Bundler and it will install the necessary dependencies for me. It will also cache gems, which solves deployment issues.
Also, it isn't possible to use only plugins, there are always gem dependencies, and I'd rather use just one mechanism, so that's another point for gems.
I think that plugins are slowly turning into gems and Rails 3 is moving further in that direction.
In my case, I use gems whenever I can but I do use plugins when I don't have access to gems on the host.
For example, Heroku doesn't have all the gems and neither does Media Temple. Since plugins are imported with the project, you can get away with it :)

Resources