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

Scaffolding with namespace generates broken partial view links with tailwind #51701

Closed
brunto opened this issue May 1, 2024 · 2 comments
Closed

Comments

@brunto
Copy link

brunto commented May 1, 2024

Steps to reproduce

  1. Generate a new tailwind rails app rails new myapp -c tailwind
  2. Generate a namespaced scaffold: bin/rails g scaffold Admin::Books name:string
  3. Run the migration: bin/rails db:migrate
  4. Change the root_path to: root "admin/books#index"
  5. Start the server: bin/dev (don't forget to install foreman)
  6. Open the index page
  7. Add a new book
  8. Go back to the index page
  9. BoOoooOommm undefined method `edit_book_path' for an instance of #<Class:0x000000012316db80>

Expected behavior

We should have the edit links working for the book.

Actual behavior

undefined method `edit_book_path' for an instance of #<Class:0x000000012316db80>

Fix

Inside the file app/views/admin/books/_book.html.erb, we should change the following:

<%= link_to "Edit this book", edit_book_path(book), class: "rounded-lg py-3 ml-2 px-5 bg-gray-100 inline-block font-medium" %>

to

<%= link_to "Edit this book", edit_admin_book_path(book), class: "rounded-lg py-3 ml-2 px-5 bg-gray-100 inline-block font-medium" %>

or maybe it's related to the module definition in: app/models/admin.rb

System configuration

Rails version: 7.1.3.2

Ruby version: ruby 3.3.1 (2024-04-23 revision c56cd86388) +YJIT [arm64-darwin23]

@flavorjones
Copy link
Member

@brunto Can you please re-open this issue on https://github.com/rails/tailwindcss-rails? Thank you!

Worth noting, some work is already being done to clean up the templates: rails/tailwindcss-rails#357

@flavorjones flavorjones closed this as not planned Won't fix, can't repro, duplicate, stale May 1, 2024
@flavorjones
Copy link
Member

See also rails/tailwindcss-rails#359 which I think fixes this issue.

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

No branches or pull requests

2 participants