[ANN] Dr Nicâ?s Magic Models

2006/8/8, Xavier N. [email protected]:

This is simple and handy:

annotate_models
http://plugins.radrails.org/directory/show/12

For visualization there’s this

Visualize Models
http://visualizemodels.rubyforge.org/

do they work when i dont have ANY model file?


Michael S. [email protected]

www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium

On Aug 8, 2006, at 5:46 PM, Michael S. wrote:

do they work when i dont have ANY model file?

The diagram for an empty model set is the empty canvas by definition!
Oh well, unless there’s some magic going on, yeah umh.

– fxn

Dr. Nic -

Think it’s possible to get constraint info from the database and figure
out additional validates_* from that? I don’t know if MySQL even has
contraints yet, but with PostgreSQL you can specify things like ‘check
age > 0 and age < 150’, etc. Another idea is that columns with unique
constraints could also translate into validates_uniqueness_of. Just a
couple ideas if you want to get crazy. :wink:

Joe

Michael S. wrote:

2006/8/8, Xavier N. [email protected]:

This is simple and handy:

annotate_models
http://plugins.radrails.org/directory/show/12

For visualization there’s this

Visualize Models
http://visualizemodels.rubyforge.org/

do they work when i dont have ANY model file?

The latter seems to only use models in the apps/models folder and
derives its associations itself, rather than using has_many/belongs_to
if defined.

Similarly for the former - no point annotating a model file if you don’t
have one :slight_smile:

But as an aside, after chatting with a few people, the next release will
include a class method on ActiveRecord::Base called
‘generate_all_classes’ (for situations where you need all your models
and their associations now).

Cheers
Nic

Think it’s possible to get constraint info from the database and figure
out additional validates_* from that? I don’t know if MySQL even has
contraints yet, but with PostgreSQL you can specify things like ‘check
age > 0 and age < 150’, etc. Another idea is that columns with unique
constraints could also translate into validates_uniqueness_of. Just a
couple ideas if you want to get crazy. :wink:

Someone pointed me to
http://www.redhillconsulting.com.au/blogs/simon/archives/000339.html
where Simon has some more code ideas on generating validations based on
the schema data that is available through the current ActiveRecord API.

Adding these will be the first upgrade to the validation generation.

Using database-type-specific meta-data might be difficult until there is
an API for exposing the data first. Not impossible - merely not my area
of expertise at the moment.

Cheers
Nic

Dr Nic wrote:

Dr Nicâ??s Magic Models will now be unveiled to all. Mystery and magic
that you will be able to perform at home.

I would love to see a console app distributed with this so that I could
do something like:

% drnic --mysql -d my_active_record_db -u username -p password

And instantly be in an IRB session with whatever database I chose.


John L.
http://wiseheartdesign.com
http://radiantcms.org

Dr Nicâ??s Magic Models will now be unveiled to all. Mystery and magic
that you will be able to perform at home.

I would love to see a console app distributed with this so that I could
do something like:

% drnic --mysql -d my_active_record_db -u username -p password

And instantly be in an IRB session with whatever database I chose.

Two things:
i) That should be possible.
ii) My ego wouldn’t allow it to be called ‘drnic’ :slight_smile:

The dynamic construction of the connection parameters from the arguments
might be difficult (read: I don’t know how I’d do that generically for
all DBs). Does anyone have/know-of a similar Ruby app that takes
connection parameters via the application arguments?

Definitely a good idea, John.

On 08/08/06, Dr Nic [email protected] wrote:

I think you’ll quickly need your models if you want to add methods and
specific associations. Plus with something like the annotate_models
plugin, you can generate a comment header to show you the schema
definition.

If you use TextMate, you might like to try Chris R.’ command which
displays the table structure in a tooltip -
http://blog.seagul.co.uk/articles/2006/07/14/textmate-command-to-display-active-record-column-attributes.
I think it’s now been incorporated into the TextMate rails bundle.

James M. wrote:

On 08/08/06, Dr Nic [email protected] wrote:

I think you’ll quickly need your models if you want to add methods and
specific associations. Plus with something like the annotate_models
plugin, you can generate a comment header to show you the schema
definition.

If you use TextMate, you might like to try Chris R.’ command which
displays the table structure in a tooltip -
http://blog.seagul.co.uk/articles/2006/07/14/textmate-command-to-display-active-record-column-attributes.
I think it’s now been incorporated into the TextMate rails bundle.

That’s sexy - I think its definitely a good idea for Rails-specific IDEs
to allow Model -> Schema view -> Model transition hot keys.

I use RadRails and it supports Model -> Unit Test -> Model windows via
Shift-Ctrl-V. Perhaps I’ll see I can get them to add a Model -> Schema
View -> Model transitions on Shift-Ctrl-S or something.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs