generate to custom file / namespace

2 views
Skip to first unread message

Lewis Hoffman

unread,
Aug 5, 2008, 4:28:51 PM8/5/08
to Dr Nic's Magic Models, trop...@gmail.com
Hi everyone,

I'm using the magic_model_generator to hook up to a legacy database.
What I want is to have the generator dump the models into a specific
directory, a specific namespace, & different inheritance.

ie. instead of

app/models/foo.rb --> class Foo < ActiveRecord::Base ...

I want

app/models/legacy/foo.rb --> class Legacy::Foo < Legacy::Base...

Any ideas how to do it? I poked around in the source a bit and I see
variables that I think hold these values, but haven't understood well
enough to monkeypatch modifications yet. Of the three changes, the
file location is the most important, others I can munge by hand later.

thanks!

Lewis

Lewis Hoffman

unread,
Aug 5, 2008, 6:53:08 PM8/5/08
to Dr Nic's Magic Models
Hi folks,

I figured out enough to pass an option for the destination directory--
here's my patch.

http://magicmodels.googlegroups.com/web/subdirectory_option.diff?gsc=iingVQsAAACybZDTMbvlNNlPmEqVyOPc

Nic Williams

unread,
Aug 5, 2008, 7:07:55 PM8/5/08
to magic...@googlegroups.com
You could probably pass another option for the common superclass and module I guess. You then provide accessors for these variables and the accessor methods can be used within the templates.

Nic
--
Dr Nic Williams
Fun with iPhone/Ruby/Rails/Javascript - http://drnicwilliams.com
* Learn TextMate for Rails2 - http://peepcode.com/products/textmate-for-rails-2 *

Reply all
Reply to author
Forward
0 new messages