ruby - How are these methods like create_table available in the Rails Migration class? -
How the methods and classes are defined in Ruby, and how to read an API document, this is a question. In short: how the Coming from the world of Java, I was hoping to provide links to base classes or mixes where everything was defined. But if I look at the I do not think how to These methods are dynamically created in this class: They are dynamically adding to the This provides for the migration class. create_table method is defined / imported / inherited, so it is available in the code in
ActiveRecord :: migration :
Create Class Products & lt; ActiveRecord :: Migration Def up_table: products do | T | T.string: name ...
migration page, I see some handwritten documents, but there is no link from the most detailed, official definition of
create_table . I used Google to find it in
ActiveRecord :: ConnectionAdapters :: SchemaStatements , but even seeing the source code of two files:
< / P> create_table to
migrate . Itemprop = "text">
CommandRecorder class The lines are then:
Class migration autoload: CommandRecorder, 'active_record / migrations / command_recorder'
Comments
Post a Comment