Topic: Learning about GEMs, Plugins, & Generator Setup/Install


I've stumbled with these a few times now and I'm wondering if there's a resource someone could recommend that explains how they work.  Specifically... the paths they use to find things and any configuration files they use--under windows.  When I open the cmd window I still have trouble figuring out what my RAILS_ROOT and RAILS_PATH are... and their not in my env.

For instance, I tried to modify the "trestle" (like scaffold) generator to do things my way... but I couldn't figure out where to put the files to make script/generate find them.  I tried 6 different combinations I found online... with no luck:

   1.  RAILS_ROOT/lib/generators
   2. RAILS_ROOT/vendor/generators
   3. RAILS_ROOT/vendor/plugins/plugin_name/generators
   4. USER_HOME/.rails/generators,
   5. gems ending in _generator
   6. built-in ones (inside rails gem)

I tried changing GEM_PATH too.

Recently, I tried to install a plugin--acts_as_favorite and I got this error:
/opt/local/lib/ruby/1.8/open-uri.rb:290:in `open_http': 404 Not Found ...

I even tried installing cygwin, because most of the things I find online talk about setting things up in your .bash_rc file, or some other unix-specific thing.  But that only made things more confusing.

So, I'm still trying to figure out where things live and how to get basic rails scripts and stuff to work again.  I'm starting to wonder if part of the issue is that I have no "rails/" directory.  I used to run all my projects out of C:/ruby/project_name, then created a c:/ruby/projects directory.  Maybe it's an issue with subversion.

I feel like I'm spending more time as a sys admin then a developer, and it's not easy to find the documentation for this stuff.  Does anyone have a suggestion?

Re: Learning about GEMs, Plugins, & Generator Setup/Install

RAILS_ROOT is set up by Rails to the top of your Rails app tree. So...

+ app
+ components
+ and so on

If you really want to know, it's set in boot.rb. Generators specific to your app go in ./vendor/generators.

Say you are creating an app called 'yabe' and you do this:

cd \
md rails
cd rails
rails yabe
cd yabe

At this point you are at the RAILS_ROOT of 'yabe'. From there, you can put a generator in c:\rails\yabe\vendor\generators\your_generator. You might consider getting a copy of Chad Fowler's "Rails Recipes" if you want to dive into messing with generators, but I'd recommend keeping it simple until you have a firm grasp of what goes where in your application tree.

...and for those of us not running windows, that might be...

cd /var/www
mkdir rails
cd rails
rails yabe
cd yabe

Last edited by cwd (2007-01-07 03:13:03)