bullet-train-pro / bullet_train-action_models

Other
5 stars 1 forks source link

Routes manipulator fails for `action-model:targets-one-parent`. #92

Closed andrewculver closed 1 year ago

andrewculver commented 1 year ago

This line fails: https://github.com/bullet-train-pro/bullet_train-action_models/blob/main/lib/scaffolding/action_model_transformer.rb#L289

To reproduce, setup an app like so:

bin/super-scaffold crud Contact Team email:text_field first_name:text_field last_name:text_field
bin/super-scaffold crud Newsletter Team name:text_field
bin/super-scaffold join-model Newsletters::Subscription contact_id{class_name=Contact} newsletter_id{class_name=Newsletter}
bin/super-scaffold crud-field Contact newsletter_ids:super_select{class_name=Newsletter}
bin/super-scaffold crud Newsletters::Issue Newsletter,Team name:text_field body:text_area

You'll need to implement the valid_newsletters method of Contact in ./app/models/contact.rb:

   def valid_newsletters
     team.newsletters
   end

Then trigger the failure with this:

bin/super-scaffold action-model:targets-one Send Newsletters::Issue Newsletter,Team