rubyatscale / packs-rails

packs-rails establishes and implements a set of conventions for splitting up large monoliths.
MIT License
270 stars 26 forks source link

Path helper methods not found inside the pack on rails 8 #96

Open matmorel opened 1 month ago

matmorel commented 1 month ago

Hello, thank you for creating this gem!

I'm trying it with rails 8.0.0.beta1 and it seems that routes defined in the packs aren't available inside it while they are in the main app:

# packs/my_pack/config/routes
scope module: :my_pack do
  resource :book
end
<%# packs/my_pack/app/views/my_pack/books/new.html.erb %>
<%= form_with url: book_path do |form| %> <%# undefined local variable or method `book_path' %>
  <%= form.text_field :title %>
<% end %>
# config/routes.rb
Rails.application.routes.draw do
  draw(:my_pack)
end
<%# app/views/home/show.html.erb %>
<%= link_to "new book", new_book_path %> <%# works %>
ashleywillard commented 1 month ago

Hi @matmorel! I'm assuming that your example is more of a generalization rather than your actual code. We noticed that there was this change in Rails 8:

Deprecate drawing routes with multiple paths to make routing faster. You may use with_options or a loop to make drawing multiple paths easier.

# Before
get "/users", "/other_path", to: "users#index"

# After
get "/users", to: "users#index"
get "/other_path", to: "users#index"

That may or may not relate to what you're seeing. Have you been able to get packs-rails working on this app with a stable version of rails?