“introspection” in Ruby on Rails

If you find yourself going to your app/models directory to look at a class that you have created with the command

ruby script/generate model ClassNameGoesHere attribute:String attribute2:String

only to find out that there is a blank class called ClassNameGoesHere in there (no field/variable declarations) its all good !

There is a thing in Ruby on Rails has a thing called introspection, this means that Rails can read the columns of the database table that the model is mapped to in order to find out what the attributes (or should I say fields now) are. I am guessing that the reason for this is the fact that you can modify the database dynamically using the migrate command.

This really is quite different, but I think I like it !

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s