-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Namespaced route with super scaffolding is missing sortable routes #511
Comments
I scaffolded the following, and the routing was properly scaffolded for me:
Resultnamespace :project do
resources :sites, concerns: [:sortable]
end
|
Sorry, I forgot I said I would do this! rails g model Listings::Contact listing:references first_name:string last_name:string prefix:string suffix:string \
position:string cell:string email:string
bin/super-scaffold crud Listings::Contact Listing,Edition,Team first_name:text_field last_name:text_field \
prefix:super_select suffix:super_select \
position:text_field cell:phone_field email:email_field --sortable I have not used |
Ran this today with the following commands since we updated the scaffolders.
Confirmed that I'm getting the same error with |
Hi there - I'm still having issues with Namespaced parent models and --sortable. I've documented them in this Discord thread: https://discord.com/channels/836637622432170028/836637623048601633/1224762468803412138 |
In short, afaict two things seem to be going wrong:
So for example, with the super-scaffold:
Then in
I haven't tried creating a fresh project to test this but I imagine it is reproducible if you just create a fresh project, create a namespaced item, and then try to use that as a parent in the chain for a sortable namespaced item. |
I assume this isn't being looked at yet. If someone could suggest a starting point I might have a look... |
@swombat here's what I'd suggest as a way to start looking into this. First get your local copy of the starter repo linked up to use a local copy of the
Then in the That will alter the So now when you run a super scaffolding command you'll be running your local code, and you can add logging statements or debugger lines to any of the core gems to try to figure out what's going on. In the This sounds at least somewhat related to another |
Cool, I'm looking into it. I've set it up as suggested. I can confirm, in case it was still in doubt, that this issue is at least still partially open. Running the following generators one after the other: rails generate super_scaffold Project Team name:text_field --sortable
rails generate super_scaffold Projects::Widget Project,Team name:text_field --sortable
rails generate super_scaffold Projects::Widgets::Item Projects::Widget,Project,Team name:text_field --sortable All execute without errors. The first two work totally fine. But here is the migration created by the third one: class CreateProjectsWidgetsItems < ActiveRecord::Migration[7.1]
def change
create_table :projects_widgets_items do |t|
t.references :widget, null: false, foreign_key: {to_table: 'projects_widgets'}
t.string :name
t.timestamps
end
end
end It's missing the class CreateProjectsWidgets < ActiveRecord::Migration[7.1]
def change
create_table :projects_widgets do |t|
t.references :project, null: false, foreign_key: true
t.integer :sort_order
t.string :name
t.timestamps
end
end
end So I'll hunt this one down first before looking at whether the routes are working. |
This commit fixes the missing sort_order: However, after running the migration, the app will still fail because of the incorrect route, once you click on the parent of the third object (
The actual routes defined:
|
As per the conversation at https://discord.com/channels/836637622432170028/1225882536203518124 I feel a bit stuck on how to fix the routes (at least the first one I see breaking). I need some advice. The line causing the issue is: <%= link_to t('.buttons.new'), [:new, :account, widget, :item], class: "#{first_button_primary(:item)} new" %> The error it causes is:
The relevant route is:
Defined by, in resources :projects, concerns: [:sortable] do
scope module: 'projects' do
resources :widgets, only: collection_actions, concerns: [:sortable] do
scope module: 'widgets' do
resources :items, only: collection_actions, concerns: [:sortable]
end
end
namespace :widgets do
resources :items, except: collection_actions, concerns: [:sortable]
end
end
end
namespace :projects do
resources :widgets, except: collection_actions, concerns: [:sortable]
end I see two possible solutions here, but I don't like either of them:
Anyone see another option? Thanks! |
https://discord.com/channels/836637622432170028/836637623048601633/1146858936356577431
In that discord link @wesgarrison reports:
New namespaced resource with super-scaffold with
--sortable
and the route can't be found with<%= url_for [:reorder, :account, context, collection] %>
rails routes
does not show me the route.I see
draw "concerns"
at the top of theconfig/routes
Looks like the sortable gem adds a concern for the route, but super scaffold only adds it for 1 of the conditional branches
bullet_train-core/bullet_train-super_scaffolding/lib/scaffolding/routes_file_manipulator.rb
Line 379 in 1744057
Looks like that was it, I added
, concerns: [:sortable]
to the route for the namespaced child and now I see the routesThe text was updated successfully, but these errors were encountered: