Skip to content
This repository has been archived by the owner on Aug 10, 2021. It is now read-only.

routes error #191

Open
JoshvaR88 opened this issue May 19, 2015 · 5 comments
Open

routes error #191

JoshvaR88 opened this issue May 19, 2015 · 5 comments

Comments

@JoshvaR88
Copy link

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 JoshvaR88 changed the title routes routes error May 19, 2015
@rsmithlal
Copy link

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.

@staycreativedesign
Copy link

I second this error with the new version

@inyerade
Copy link

inyerade commented Jun 22, 2021

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

@staycreativedesign
Copy link

staycreativedesign commented Jun 22, 2021 via email

@inyerade
Copy link

I think I found the problem, but I do not know the best way to fix it.

The problem is the locales, in lines

locales = (if Spree.respond_to?(:available_locales)
Spree.available_locales
else
I18n.available_locales
end).join('|')
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})+}

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]

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants