citrus / spree_essential_cms

SpreeEssentialCms is a full featured CMS for Spree Commerce.
BSD 3-Clause "New" or "Revised" License
68 stars 82 forks source link

Remove 'catch all' routes? #25

Open lafeber opened 12 years ago

lafeber commented 12 years ago

Hi,

Even when visiting a non-cms related page, I still see a call to pages.

Started GET "/nl/t/categories/dresses" for 127.0.0.1 at 2012-06-04 15:59:04 +0200
  Processing by Spree::TaxonsController#show as HTML
  Parameters: {"id"=>"categories/dresses", "locale"=>"nl"}
  Spree::Page Load (0.5ms)  SELECT `spree_pages`.* FROM `spree_pages` WHERE `spree_pages`.`path` = '/t/categories/dresses' ORDER BY position LIMIT 1
  Spree::Page Load (0.9ms)  SELECT `spree_pages`.* FROM `spree_pages` WHERE `spree_pages`.`accessible` = 1 AND `spree_pages`.`visible` = 1 ORDER BY position
  Spree::Taxon::Translation Load (0.2ms)  SELECT DISTINCT locale FROM `spree_taxon_translations`  (...etc...)

I would suggest a /pages/ prefix, it's not as nice, but fixes the assets routing problem as well.

  Started GET "/spree/products/3603/small/Jill.jpg" for 127.0.0.1 at 2012-06-04 16:12:09 +0200
    Spree::Page Load (0.4ms)  SELECT `spree_pages`.* FROM `spree_pages` WHERE `spree_pages`.`accessible` = 1 AND `spree_pages`.`path` = '/spree/products/3603/small/Jill.jpg' ORDER BY position LIMIT 1

  ActionController::RoutingError (No route matches [GET] "/spree/products/3603/small/Jill.jpg"):

Is this an idea?

PS: If I'm the only one with this issue, my Gemfile looks like this:

  gem 'spree_essentials', '~> 0.4.rc2'
  gem 'spree_essential_blog', :git => 'git://github.com/citrus/spree_essential_blog.git', :branch => '1.0.x'
  gem 'spree_essential_cms', '~> 0.3.0.rc1'
citrus commented 12 years ago

I have battled with this issue several times before both on the CMS and on the blog. We absolutely need to keep the ability to have dynamic pages with top-level paths.

How do other CMS's handle this?

lafeber commented 12 years ago

For the blog, it might help to implement the same constraints as the cms? I think this would help in not matching the assets...

I'll try to implement this based on the answer found here: http://stackoverflow.com/questions/7688023/rails-3-making-a-catch-all-route-easier-to-read-and-amend

...somewhere next week. First, I'm migrating spree_multi_currency to our version of Spree.

PS (unrelated): integrating multiple languages in the cms/blog was a breeze, it followed the same steps as spree_multi_lingual. Some migrations and a few overrides and it worked. Really cool. Hopefully I'll have time to publish some of this somewhere next month.