There's really no magic to it: since the Page id parameter is coming in the
form of "123-page-title-goes-here", Rails just calls #to_i on anything that
comes into ActiveRecord#find, so that parameter just gets turned into "123".

Actually, this should probably be updated to use friendly_id, the way User
does (see:
https://github.com/bborn/communityengine/blob/master/app/models/user.rb#L13).
This would allow you to use custom slugs, as you're describing.



On Mon, Mar 18, 2013 at 10:51 AM, Dan Coutu <co...@snowy-owl.com> wrote:

> I see that the page model seems to have the ability to find a page by
> either id or a slug that's made up of a combination of id and parameterized
> title. However the page model provides no method for this extension of the
> find method and I haven't found any gem or plugin that seems to handle it
> either.
>
> The reason that this is important to me is that I want to be able to use a
> type of slug that doesn't rely on either the id or the title so that I can
> readily create links to static pages based on a slug value that won't
> change even if the page title or id does change. (The id would change if
> the original page was deleted and a new one created, or if the slug on the
> original was removed and assigned to a different page.) Examples of such
> pages are: About Us, Privacy Policy, Terms and Conditions.
>
> What I'm really asking here is if anyone knows how to override the find
> method for pages so that it supports both the current lookup as well as my
> own slug lookup. I'm a bit reluctant to just declare an override in my
> local page model without first seeing what the current code looks like, so
> that I don't make a mess of things.
>
> Dan
>
> --
> You received this message because you are subscribed to the Google Groups
> "CommunityEngine" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to communityengine+unsubscr...@googlegroups.com.
> To post to this group, send email to communityengine@googlegroups.com.
> Visit this group at http://groups.google.com/group/communityengine?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"CommunityEngine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to communityengine+unsubscr...@googlegroups.com.
To post to this group, send email to communityengine@googlegroups.com.
Visit this group at http://groups.google.com/group/communityengine?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to