Models with relationships through join tables not supported
Created by: cristianriano
- What were you trying to do?
I have a relationship many-to-many (HABTM) in my code (cocktails..ingredients). I used the ActiveRecord method create_join_table to create the join table (portions), which means it has no ID field on it's own.
For the model I declared the relationship both with has_and_belongs_to_many
and has_many ... through:
.
Then I generated the dashboards and controllers for my app and try to visit the show of one of the instances
- What did you end up with (logs, or, even better, example apps are great!)?
I get a ActionController::UrlGenerationError in Admin::Cocktails#show
error
No route matches {:action=>"show", :controller=>"admin/portions", :id=>nil}, missing required keys: [:id]
- What versions are you running?
- Ruby 3.0.0
- Rails 6.1.1
- Administrate 0.14
I know it's happening because the join table doesn't have an ID, but how is this case mean to be handled with the gem? Is there something I'm missing or I just need to add the ID?