Determining the Page Missing Behavior

Currently Page Missing is a fairly hardcoded thing. If I wanted to
create a new page missing behavior, I would have to do so by modifying
the behavior of the parent to look for my new type of page missing
behavior - This is because the page missing behavior is found based on
behavior_id.

I’d like to suggest that this actually be determined in another manner,
possibly falling back to the behavior_id. I like the idea of looking for
a page with “404” as it’s slug, or some other string that seems
appropriate. What say you?

As an example of what I’d like to do, I want to introduce a ‘best guess’
page missing behavior that tries to find a matching page and if so
redirects to that page, so that if there are the pages at the slugs:

/monkeys-are-good
/monkeys-are-bad

then a request to /monkeys-are-g would get redirected to the first page,
as would a request for /monkeys-are-good-arent-they or
/monkeys-are-good.fdasa - a request to /monkeys-are would end up
actually rendering the page missing page, as it couldn’t tell which is
which (though the behavior might want to render the list of possibly
matching urls). This is really useful when people email your links
around and they end up getting slightly truncated due to line-wrapping
or get extra punctuation from a bad cut/paste or a mail-agent that can’t
tell tell that http://www.google.com/search. is not meant to have that
trailing period.

Other parts of your site might have aliases - such as obseleted products
where there’s a table mapping old products to new names and you want to
take advantage of that table to send people to the right location.

Dan.

Daniel S. wrote:

Currently Page Missing is a fairly hardcoded thing. If I wanted to
create a new page missing behavior, I would have to do so by modifying
the behavior of the parent to look for my new type of page missing
behavior - This is because the page missing behavior is found based on
behavior_id.

I’d like to suggest that this actually be determined in another manner,
possibly falling back to the behavior_id. I like the idea of looking for
a page with “404” as it’s slug, or some other string that seems
appropriate. What say you?

Yeah, it was done wrong to begin with. I’d accept a patch that added a
#page_missing? instance method to Behavior::Base that returned false and
an overwridden method on PageMissingBehavior which returned true.


John L.
http://wiseheartdesign.com

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs