I have a Vehicle model:
Routes:
map.resources :vehicles, :has_many => :suppliers
Everything works great, but Vehicle has a boolean attribute is_truck. I want to make an Alias so I can get the same resources filtering only trucks, I tried with:
Routes:
map.trucks '/trucks', :controller => :vehicles, :action => :index, :is_truck => true
map.trucks '/trucks/by_supplier/:supplier', :controller => :vehicles, :action => :index, :is_truck => true
The first one works well, but when I search within a Form the second doesn't work and searches all suppliers.
Controller:
class VehiclesController
def index
if params[:supplier]
@vehicles = Vehicle.all :conditions => { :is_truck => params[:is_truck] }
else
@vehicles = Vehicle.all
end
end
...
end
Search Form:
<% form_for :truck, :url => {:controller => :trucks, :action => :index}, :html => {:method => :get} do |f| %>
<% f.text_field :search %>
<% f.submit 'Search Trucks' %>
<% end %>
Is it possible to map.resources as an alias ?