spree_static_content
spree_static_content copied to clipboard
routes error
No route matches [GET] "/thanks"
when i click the page link i'm getting this error
localhost:3000/thanks No route matches [GET] "/thanks"
I'm having the same error, but only for pages that were migrated to my database from my coworker's MYSQL database. Previously created pages load just fine.
Update I think it may have been because my coworker sent me the sql for just the spree_pages table and not the spree_pages_translations table. I'm assuming because they weren't initialized correctly it didn't work. as soon as I ran a migration to add my own pages with the same details, everything worked fine.
I second this error with the new version
@staycreativedesign you solve your problem?
Same problem here
- spree 4.2.1
- spree_static_content 4.2.0 (from github 'spree-contrib/spree_static_content')
and I get:
ActionController::RoutingError (No route matches [GET] "/test2")
I pretty much just built my own static content gem.
On Tue, Jun 22, 2021 at 11:27 AM inyerade @.***> wrote:
@staycreativedesign https://github.com/staycreativedesign you solve your problem?
Same problem here
- spree 4.2.1
- spree_static_content 4.2.0 (from github github: 'spree-contrib/spree_static_content')
and I get:
ActionController::RoutingError (No route matches [GET] "/test2")
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/spree-contrib/spree_static_content/issues/191#issuecomment-866136941, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAO4XUR7IY4ZFGYZRQOYBWDTUC2XLANCNFSM4BD7GIQQ .
I think I found the problem, but I do not know the best way to fix it.
The problem is the locales, in lines
https://github.com/spree-contrib/spree_static_content/blob/57953abd2d2151aa94d2db16e040243a48496436/lib/spree_static_content.rb#L19-L24
the regexp match the te
locale, also every word that match the initial of any locale will going to fail.
FAIL:
/test (match te
)
/esto (match es
)
PASS: /foo /asd
also fail only with:
path_regex = %r{\A/+(#{ locales }+}
Possible solutions (I never work with locales in spree)
- add / at the end of each locale
locales = (if Spree.respond_to?(:available_locales)
Spree.available_locales
else
I18n.available_locales
end).join('/|') + "/"
- add / at the en of regexp pattern
path_regex = %r{\A/+(api/v|api_tokens|admin|account|cart|checkout|content|login|pg/|orders|products|s/|session|signup|shipments|states|t/|tax_categories|user|rails/active_storage|#{locales})+/}
- Use a previous condition for locales, some like:
return false if locales.include? request.path.split("/")[0]