I have a question but I since I do not understand thor so much I would like
to have feed back from anyone that would like to help me here.
While going through the code in:
rails <https://github.com/rails/rails> /
activerecord<https://github.com/rails/rails/tree/master/activerecord>
/ lib <https://github.com/rails/rails/tree/master/activerecord/lib> /
rails<https://github.com/rails/rails/tree/master/activerecord/lib/rails>
/
generators<https://github.com/rails/rails/tree/master/activerecord/lib/rails/generators>
/
active_record<https://github.com/rails/rails/tree/master/activerecord/lib/rails/generators/active_record>
/
model<https://github.com/rails/rails/tree/master/activerecord/lib/rails/generators/active_record/model>
/ *model_generator.rb*
there is this piece of code:
def create_migration_file
return unless options[:migration] && options[:parent].nil?
attributes.each { |a| a.attr_options.delete(:index) if a.reference?
&& !a.has_index? } if options[:indexes] == false
migration_template
"../../migration/templates/create_table_migration.rb",
"db/migrate/create_#{table_name}.rb"
end
It looks that model generator is coupled to migration generator. My
question is if it would not be more proper to invoke the migration
generator instead of creating the migration template file here. Migration
generator should be the only one creating migration files. So by invoking
the migration generator both migration and model generators would be
decoupled.
I tried to do something like:
def create_migration_file
return unless options[:migration] && options[:parent].nil?
attributes.each { |a| a.attr_options.delete(:index) if a.reference?
&& !a.has_index? } if options[:indexes] == false
invoke :migration, ["create_#{table_name}"]
end
but arguments from CLI are not being passed.
I tried to hack a bit and even when I passed the args to the invoke call
then I have a problem with the options
Is there a way to do what I have in mind or thor does not allow to do this?
Waiting for feedback.
Thank you
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to rubyonrails-core+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.