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

No route matches [GET] after changing code (helper, model) #464

Open
qrooel opened this issue Jun 18, 2024 · 3 comments
Open

No route matches [GET] after changing code (helper, model) #464

qrooel opened this issue Jun 18, 2024 · 3 comments

Comments

@qrooel
Copy link

qrooel commented Jun 18, 2024

Hello!

Using newest hotwire branch - I have some problems with code reloading.

Gemfile:

gem 'trestle', branch: 'hotwire', git: 'https://github.com/TrestleAdmin/trestle.git'
gem 'trestle-auth', branch: 'hotwire', git: 'https://github.com/TrestleAdmin/trestle-auth.git'

Imagine that I use this kind of code in my Trestle resource:

Trestle.resource(:attachment) do
  controller do
    def update
      instance.all_attachments
    end
  end
end

#all_attachments method inside the model:

  def all_attachments
    [avatars, pictures, videos].flatten
  end

If I change anything inside all_attachments method, then I get this error:
No route matches [GET] "/ta/file_uploads/1"

This happens for all the code, not only for all_attachments method.
No matter where I put the code: model, helper, decorator - if I change anything, then I got an error.

I guess that I have some missing configuration on my side that reloads application code.

What I do to fix that?

  • I have to restart rails server
  • or I have to change something inside Trestle resource file (maybe doing so clears cache?)

Thanks for any help!

@spohlenz
Copy link
Member

I've generally seen two main cases where this particular error happens No route matches [GET] ...:

  1. When there is a syntax error in the _admin.rb file for the admin you are trying to access. In this case, check your rails logs a little further up to see if there are any errors prior to the error from the latest request.

In this situation, you may find restarting your rails server throws the same error, but it should pinpoint it more closely.

  1. The other situation is when a table column is trying to link to another admin that may not exist. If you are using the admin_link_to helper, you can specify an admin: option explicitly. Is there something in your table block that is referencing all_attachments?

You mention using the new hotwire branch -- I'd be curious to know if the previous release didn't show these errors, as that would be surprising to me.

@qrooel
Copy link
Author

qrooel commented Jun 19, 2024

Thanks for the comment!

Unfortunately none of those tips helped. ;/

Is there something in your table block that is referencing all_attachments?

No, errors could happen in almost empty resource file, like in the example above.

In the logs, after I change something in the helper/model, I see bilder.rb warnings, so I guess those errors are related with code reloading mechanism.
web-1 | ActionController::RoutingError (No route matches [GET] "/ta/valuations/164"): web-1 | web-1 | /root/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/bundler/gems/trestle-8ee02e492f8e/lib/trestle/admin/builder.rb:25: warning: already initialized constant ActionsAdmin web-1 | /root/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/bundler/gems/trestle-8ee02e492f8e/lib/trestle/admin/builder.rb:25: warning: previous definition of ActionsAdmin was here web-1 | /root/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/bundler/gems/trestle-8ee02e492f8e/lib/trestle/admin/builder.rb:25: warning: already initialized constant Trestle::Auth::AccountAdmin web-1 | /root/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/bundler/gems/trestle-8ee02e492f8e/lib/trestle/admin/builder.rb:25: warning: previous definition of AccountAdmin was here web-1 | /root/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/bundler/gems/trestle-8ee02e492f8e/lib/trestle/admin/builder.rb:25: warning: already initialized constant CalculationsAdmin web-1 | /root/.asdf/installs/ruby/3.3.1/lib/ruby/gems/3.3.0/bundler/gems/trestle-8ee02e492f8e/lib/trestle/admin/builder.rb:25: warning: previous definition of CalculationsAdmin was here

I will dig some more, thanks!

@spohlenz
Copy link
Member

Would you possibly be able to upload a minimal example application to GitHub that shows the issue? I'd love to get to the bottom of what is happening here but I haven't been able to reproduce it so far.

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