phlex-ruby / phlex-rails

An object-oriented alternative to ActionView for Ruby on Rails.
https://www.phlex.fun
MIT License
232 stars 40 forks source link

Nested path generate wrong URL #200

Closed oztofer closed 5 months ago

oztofer commented 5 months ago

Hi, i'm using phlex (1.10.3) and phlex-rails (1.2.1), The following should result "/adm/mpl/orders/10/users/56" but result nil

namespace :adm do
  namespace :mpl do
    resources :orders do
      resources :users
    end
  end
end

include Phlex::Rails::Helpers::Routes
adm_mpl_order_user_path(order_id: 10, id: 56)

But this works fine

app_route = Rails.application.routes.url_helpers
app_route.adm_mpl_order_user_path(order_id: 10, id: 56)

result: "/adm/mpl/orders/10/users/56"

joeldrapper commented 5 months ago

That’s very strange because the routing helpers come directly from that module. See https://github.com/phlex-ruby/phlex-rails/blob/b9d9d676ee0699f78c496ee32d5fc5d52c4e26d7/lib/phlex/rails/helpers/routes.rb#L7

oztofer commented 5 months ago

Sorry i fixed the question, "adm_mpl_order_user_path(order_id: 10, id: 56)" creates nil result

joeldrapper commented 5 months ago

I wrote a test to try to reproduce this and it passed. 🤷‍♂️

https://github.com/phlex-ruby/phlex-rails/compare/main...nested-paths

joeldrapper commented 5 months ago

@oztofer I’m going to close this for now as I don’t think the issue is in Phlex. If you can reproduce the issue in either a fresh rails app or in the dummy rails app in our test folder, please reopen.