What I have done in the past when I had an Article model and wanted to have
string based URLs (instead of ID numbers) was to add a property on my model
named "url". I then populated that property after create based on the
article's title and if there was already a duplicate, I prepended a number
to the end. So, if the article was named "Hello World", the url property
would end up being "Hello_world". The next time a hello world article was
created, the url would become "Hello_world_2". Then, my router file ended up
looking like this:
identify Article => :url do
match("/:url").to(:controller => "articles", :action =>
"show").name(:article)
end
and in my views, I would simply do url(:article, @article) which would
generate /Hello_world
Hope this helps.
-carl
On Tue, Sep 23, 2008 at 10:28 AM, felix <[EMAIL PROTECTED]> wrote:
>
> it all looks very nice.
>
> I am interested in a best practice for having nice urls. These are
> things I have considered:
>
> * having a serial id property is good as a text based keys cannot be
> changed (I believe)
> * therefore, using the new 'indentify' call in the router we can now
> do what 'to_param' used to do but using any method/property we desire
> * I personally would prefer urls that don't have the integer prefix
> ie. '67-some-listing-title'
>
> What do people think would be the simplest way to have this all setup
> and not require too many changes to existing controller logic that
> uses Datamapper? Is there a more specific write up on the way that you
> know of?
>
> -felix
>
> On Sep 22, 2:16 am, Carl Lerche <[EMAIL PROTECTED]> wrote:
> > Hey everybody,
> >
> > Just as a heads up, the new merb router branch got merged into master
> > yesterday. Although, current router.rb files probably won't need much
> > work to upgrade, there are a lot of pretty significant changes and a
> > lot of nifty new features.
> >
> > I wrote up a brief overview of the most significant changes herehttp://
> github.com/carllerche/merb-core-enterprise-edition/wikis/whats....
> > You can reply to this message or hit up the IRC channel with any
> > questions that you might have.
> >
> > -carl
> >
>
--
EPA Rating: 3000 Lines of Code / Gallon (of coffee)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---