How to handle a non existing action in a controller?

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

Anyone? :slight_smile:

def method_missing(method)
end

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.

Thanks a lot for the feedback, i got it working now!