activerecord_model_generator.rb

3 views
Skip to first unread message

Martin Hawkins

unread,
Aug 17, 2009, 9:39:49 AM8/17/09
to Rucola
Further to my problem already posted (generate activerecord error
message), I was taking a look at the above in an effort to work out
where the problem lay. I've only managed to confuse myself further.

'ruby script/generate activerecord_model' produces the following:

Usage:

ruby script/generate activerecord_model FooBar

This will create:
app/models/foo_bar.rb
app/models/foo_bar_proxy.rb
db/migrate/create_foo_bars.rb

Looking at the code for activerecord_model_generator.rb, we see an
initializer method defined as follows:

def initialize(runtime_args, runtime_options = {})
super
usage if args.empty?
@name = args.shift
@proxy_name = @name.camel_case + "Proxy"
@nibs_to_update = args
@app_name = Rucola::InfoPlist.open(destination_path
('Info.plist')).app_name.snake_case
extract_options
end

So, when I run 'ruby script/generate activerecord_model Author', my
understanding is
args = [Author],
so @name = args.shift means that @name = "Author"
and @proxy_name = "AuthorProxy"
and args becomes [].
This means that @nibs_to_update = [] and so the code defined in the
manifest method as follows
@nibs_to_update.each do |nib|
if nib.camel_case == 'MainMenu'
add_classes_to_nib('misc/English.lproj/MainMenu.nib/
classes.nib')
else
add_classes_to_nib("app/views/#{nib.camel_case}.nib/
classes.nib")
end
end
will never run.

Or am I wrong?

alloy

unread,
Sep 23, 2009, 1:05:56 PM9/23/09
to Rucola
Sorry for the lack of reply, I suspect Mail.app started marking all
mail from this list to aggressively.

Anyhoo, I'm unhappy with a lot of the code, including the generators.
As I've just said in an email about the spam issues, I am working on
the MacRuby rewrite of Rucola, which amongst others will feature clean
lean generators.

HTH,
Eloy
Reply all
Reply to author
Forward
0 new messages