Skip to content
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

Ensure custom namespace routes are scaffolded properly #35

Merged
merged 1 commit into from
Feb 15, 2023

Conversation

gazayas
Copy link
Contributor

@gazayas gazayas commented Dec 28, 2022

Closes bullet-train-co/bullet_train#428

Previously bullet-train-co/bullet_train-super_scaffolding#80

Details

I wanted to use RoutesFileManipulator#apply to add the routes, but since we're using draw, I don't think we'll be able to scaffold the routes properly with it because apply depends on parent blocks. We've already written the proper routes within the new custom namespace file, so I just added the draw lines to each original routes file.

Example

> rails g model Job team:references title:string
> bin/super-scaffold crud Job Team title:text_field --namespace=client

config/routes.rb

Rails.application.routes.draw do
  # See `config/routes/*.rb` to customize these configurations.
  draw "concerns"
  draw "devise"
  draw "sidekiq"
  draw "client"

  ...
end

config/routes/api/v1.rb

# See `config/routes.rb` for details.
collection_actions = [:index, :new, :create] # standard:disable Lint/UselessAssignment
extending = {only: []}

shallow do
  namespace :v1 do
    draw "client"

    ...
  end
end

Example rails routes --expanded output

Prefix            | 
Verb              | POST
URI               | /client/teams/:team_id/jobs(.:format)
Controller#Action | client/jobs#create
Prefix            | 
Verb              | POST
URI               | /api/v1/client/teams/:team_id/jobs(.:format)
Controller#Action | api/v1/client/jobs#create

@andrewculver andrewculver merged commit d2a02a1 into main Feb 15, 2023
kaspth added a commit that referenced this pull request Feb 22, 2023
* main: (47 commits)
  Fixes for `number_field` (#113)
  DRY translations. (#43)
  Remove TODO about platform_agent (#92)
  Prevent duplicate lines in `roles.yml` (#114)
  Remove Devise monkey patch (#123)
  Extract team index item into a theme component partial (#117)
  1.2.11
  Revert "Adds multiple file upload (#10)" (#108)
  Fixing Standard Ruby.
  Update application locale in `bump_api` rake task (#47)
  (feat) adds number as a possible input and attribute (#32)
  Define User strong parameters based on attributes being updated (#17)
  Adds multiple file upload (#10)
  typo regarding preview_image_options (#3)
  Ensure custom namespace routes are scaffolded properly (#35)
  Redirect to show page when creating a new record (#49)
  Add documentation for `emoji_field` (#53)
  stringify_keys on options returned from options_for helper (#59)
  Fix profile image background color (#61)
  Make menu keyboard accessible (#57)
  ...
@gazayas gazayas deleted the fixes/custom-namespace-bug branch August 9, 2023 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Defining custom namespace overwrites routes.rb
2 participants