resolve/refinerycms — Issue #1114: Sluggable Problems
Author: matellis
Created: 2011-10-30 19:31:42+00:00
State: open

I'm working with refinerycms-pages and some custom layouts.

The custom layouts work like this:

`
# /app/controllers/pages_controller.rb
class PagesController < ApplicationController
def home
error_404 unless (@page = Page.where(:link_url => '/').first).present?
end

def features
@page = Page.find('features')
end
end

# /config/routes.rb
match '/features', :to => 'pages#features'
`

We have two settings/variables in Refinery under our control:

1. use_marketable_urls in RefineryCMS::Settings
2. 'Custom Title' in the page record 'advanced options'

We want the page 'Features' to be accessible at '/features' and to appear in the menus as such. Our menu code uses the `menu_branch.url` method to get the right URL.

Thanks to the `routes.rb` change our page is *always* available at '/features' but the menus behave differently. Depending on which settings we use we get one of two results:

1. Page urls in the menu are consistently in the form '/pages/features'
2. Page urls randomly switch between '/features' and '/features-page'

Our custom layouts only work when you go to '/features', '/pages/features' and '/features-page' don't trigger the layouts.

Looking at `refinerycms-pages` code there is a method `sluggable` that should only be run if the Use Marketable Settings is on *and* there is no custom title, but for some reason it seems to randomly run.

For now we will simply set the menu URLs statically but I think there's a bug in here somewhere, either in our understanding of the interaction between `sluggable`, `use_marketable_urls` and the Custom Title field.

Any help would be much appreciated.