spree_static_content icon indicating copy to clipboard operation
spree_static_content copied to clipboard

routes error

Open JoshvaR88 opened this issue 9 years ago • 5 comments

No route matches [GET] "/thanks"

when i click the page link i'm getting this error

localhost:3000/thanks No route matches [GET] "/thanks"

JoshvaR88 avatar May 19 '15 05:05 JoshvaR88

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.

rsmithlal avatar Jul 14 '15 15:07 rsmithlal

I second this error with the new version

staycreativedesign avatar Nov 19 '20 23:11 staycreativedesign

@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")

inyerade avatar Jun 22 '21 16:06 inyerade

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 .

staycreativedesign avatar Jun 22 '21 16:06 staycreativedesign

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)

  1. add / at the end of each locale
     locales = (if Spree.respond_to?(:available_locales)
                   Spree.available_locales
                 else
                   I18n.available_locales
                 end).join('/|') + "/"
  1. 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})+/}
  1. Use a previous condition for locales, some like:
    return false if locales.include? request.path.split("/")[0]

inyerade avatar Jun 22 '21 23:06 inyerade