Hello, i'm currently building a website in which i have to customise the url to the data. An example: i have a company which is situated in Amsterdam and it's name is Ruby, then i would like to have the following URL: /companies/amsterdam/ruby/ But since there are a lot of cities that have companies i can't make a define for all of these. How to fix? Thanks in advance, Rick
on 2005-12-29 22:53
on 2005-12-29 23:55
on 2005-12-30 00:35
def method_missing(method) end
on 2005-12-30 00:36
You could set up a route in config/routes.rb something like: map.connect '/companies/:city/:company_name', :controller => 'companies', :action => 'show' That would give you params[:city] and params[:company_name] to work with. So in your controller you could do something like: class CompaniesController < ApplicationController def show @company = Company.find_by_name(params[:company_name]) @city = City.find_by_name(params[:city]) end end Hope that is a start.
on 2005-12-30 14:28
Thanks a lot for the feedback, i got it working now!