views:

41

answers:

1

Hi, I am new to Ruby On Rails, and currently trying to modify an existing (uncomplete) plugin from github. Things went smoothly until I am trying to add new models to this plugin.

I know script/generate model, and script/generate plugin. But how to add models into a plugin without regenerate the whole plugin? I don't want rewrite the plugin to add functions to it, and script/generate model vendor/plugin/myPlugin wilt generate other stuff into the whole project rather than the plugin directory.

Probably I could write the model class file myself, but how about migration, create my own rake file?

Note: The plugin has more than one classes and a couples of migrate schema named as datetime_create_model_name.rb. But I couldn't find any generator in the plugin Dir?

A: 

Write a generator for the plugin, to create the migration scripts for the new model. Refer to some of the existing plugins, to learn how to write a generator.

Here is one example:

1) Generator file

2) Migration template file

KandadaBoggu
Hi, KandadaBoggu, as my notes, there is no generator file in the plugin folder, but a few migration files, how did those migration classes been created?
pstar
They are hand coded. You should be able to create them too.
KandadaBoggu
En, seems make sense, is the time stamp in the file name required by rake db:migrate ?
pstar
No. Its really up to you to decide if you need the time-stamp fields in your model.
KandadaBoggu