How to use string interpolation when rendering templates?

Posted by Senthil on Stack Overflow See other posts from Stack Overflow or by Senthil
Published on 2010-04-28T03:01:09Z Indexed on 2010/04/28 3:13 UTC
Read the original article Hit count: 230

Filed under:

I found this code in a Rails cookbook.

class BlogController < ApplicationController

def display_by_date
 year = params[:year]
 month = params[:month]
 day = params[:day]
 day ='0'+day if day && day.size == 1
 @day = day
 if ( year && month && day )
  render(:template => "blog/#{year}/#{month}/#{day}")
 elsif ( year )
  render(:template => "blog/#{year}/list")
 end
end

end

I'm not sure what to name the templates so the router can find them. Thanks for your help.

© Stack Overflow or respective owner

Related posts about ruby-on-rails