TrestleAdmin / trestle

A modern, responsive admin framework for Ruby on Rails
https://trestle.io
GNU Lesser General Public License v3.0
1.97k stars 177 forks source link

ActionController::RoutingError (No route matches [GET] "/fa-solid-900.ttf") bump from 0.9 to 0.10 #479

Closed eddygarcas closed 2 months ago

eddygarcas commented 2 months ago

I've just update Trestle admin version from 0.9 to 0.10 an running the server i start getting this route not match error:

ActionController::RoutingError (No route matches [GET] "/fa-solid-900.ttf"):

I ran the rails generate trestle:install afterwards just i case, but no luck. Also I have a custom theme to change the background colors, etc...but they are not picked up.

Any help?

spohlenz commented 2 months ago

I've just update Trestle admin version from 0.9 to 0.10 an running the server i start getting this route not match error:

ActionController::RoutingError (No route matches [GET] "/fa-solid-900.ttf"):

First off, I assume you're using Sprockets (rather than Propshaft) since it's an upgrade. Let me know if that's incorrect.

Trestle 0.10.0 now includes the stylesheets with the FontAwesome Sprockets paths separately -- https://github.com/TrestleAdmin/trestle/blob/main/app/views/layouts/trestle/admin.html.erb#L19.

Do you see that <link> tag being output?

<link rel="stylesheet" href="/assets/trestle/icons/font-awesome.debug-f6575a715181bbbd79ccbec8156ebb917e7a8081aa288ab7333663f37f3c0d48.css" data-turbo-track="reload" />

One thing that might help is to clear out any stale assets and Sprockets caches:

$ rails assets:clobber
$ rails tmp:cache:clear

Also I have a custom theme to change the background colors, etc...but they are not picked up.

Theming in Trestle 0.10.0 works a little differently to previous versions, in order to remove the requirement for a Sass compiler. Instead of defining theme variables within app/assets/stylesheets/trestle/_custom.scss, the primary and secondary colors can now be set within config/initializers/trestle.rb:

# Define primary and secondary theme colors. Color values may be specified
# as either 3- or 6-digit hex codes, or rgb/hsl() triplets.
config.theme = { primary: "#338ab7", secondary: "#719dc3" }

Any other CSS customizations can be added to app/assets/stylesheets/trestle/custom.css.

eddygarcas commented 2 months ago

Theming in Trestle 0.10.0 works a little differently to previous versions, in order to remove the requirement for a Sass compiler. Instead of defining theme variables within app/assets/stylesheets/trestle/_custom.scss, the primary and secondary colors can now be set within config/initializers/trestle.rb:

regarding styles, that made the trick, thanks, I was able to move all the styles into custom.css and setup the primary and secondary in the initializer.

Do you see that tag being output?

I saw that admin.html.erb has this stylesheet link tag defined: <%= stylesheet_link_tag "trestle/icons/font-awesome", 'data-turbo-track': 'reload' if defined?(Sprockets) %> and I don't see this line inspecting the resultant html code but getting the routing error. I'll review the whole app configuration see if I can find a root cause for that.

Also not sure if this is related but I've got some custom actions that fail with same RoutingError:

13:31:43 web.1  | Started GET "/admin/clients/608e3489-3ca7-481d-abee-484f9992b2af/reset" for 127.0.0.1 at 2024-08-30 13:31:43 +0200
13:31:43 web.1  |   
13:31:43 web.1  | ActionController::RoutingError (No route matches [GET] "/admin/clients/608e3489-3ca7-481d-abee-484f9992b2af/reset"):

The route definition is what was implemented as desribed in the wiki actually I can see the route doing rails routes

reset_clients_admin POST /clients/:id/reset(.:format) clients_admin/admin#reset

mattbee commented 2 months ago

We're also experiencing routing errors in our app, for example the following route worked on 0.9.0 but it gives a 404 in the browser.

Trestle.resource(:our_model) do
  ...
  controller do
    def controller_method
      ...do stuff...
    end
  end

  routes do
    post :controller_method, on: :member
  end
end

As a side note, it seems to work in 0.9.0 and 0.10.0 in our RSpec suite, but just not in the browser (I am currently treble checking our tests are not somehow still using 0.9.0 despite defining 0.10.0 in our Gemfile for the test)

Additional Version Info: Ruby 3.1.4 Rails 7.1.4 RSpec 3.13.0

spohlenz commented 2 months ago

@mattbee There haven't been any changes on the routing side between the two versions (and you can also verify the route is active using the rails routes command.

However I am guessing you have a link that is using the old Rails-UJS style with method: :post. This will need to be changed to data: { turbo_method: :post } for 0.10.0. I am thinking it may be worth putting in an automatic conversion for 0.10.1.

eddygarcas commented 2 months ago

turbo_method: :post

Yes, that worked for me. Thanks.