Hey there,

I am trying to figure out routing and thought that this would probably
be the best way to learn how to do some complicated routes. I've
looked at a lot of people's methods for getting the /articles/
2009/02/12/some-title to work but they all seem to forget to post some
custom method they're writing like by_date.

So here was my stab at it, I know I need to gsub the title. I just
don't know where (in the conditions?)

<code>
// routes.rb
map.article_page 'articles/:year/:month/:title', :controller =>
'articles', :action => "show",
    :requirements => { :year => /(19|20)\d\d/, :month => /[01]?\d/ }

// articles_controller.rb
def show
    @article = Article.find_by_date(params)
    ...

// article.rb
def self.find_by_date(params)
    find(:first, :conditions => ["publish_date.year = ? and
publish_date.month = ? and title = ?", params[:year], params[:month],
params[:title]])
  end
</code>

I know publish_date.year is wrong but I can't figure out a way to pull
the year out of the publish_date column here.

Any help would be surely appreciated.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to