Topic: Another routing question
Hello guys
This is what I want to do:
I have a Trip model with a load_on date, I want to make a route like this: trips/year/month/day
Right now I have this is my controller:
def index
@trips = Trip.find(:all, :conditions => ['YEAR(load_on) = ? AND MONTH(load_on) = ? AND DAY(load_on) = ?', params[:year], params[:month], params[:day]])
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @trips }
end
end
and routes.rb
map.resources :tripsmap.connect 'trips/:year/:month/:day', :controller => 'trips',
:month => nil, :day => nil, :requirements => { :year => /\d{4}/ }
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
But my index action now doesn't display anything, I guess I am not doing something right in routes.rb
Last edited by leTus (2008-04-16 04:56:10)