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 -- Posted via http://www.ruby-forum.com/.
Anyone? :-) -- Posted via http://www.ruby-forum.com/.
Terje Pedersen
2005-Dec-29 23:32 UTC
Re: Re: How to handle a non existing action in a controller?
def method_missing(method) end _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Jeremy Maziarz
2005-Dec-29 23:36 UTC
Re: How to handle a non existing action in a controller?
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. -- Posted via http://www.ruby-forum.com/.
Possibly Parallel Threads
- undefined method 'sanitize_limit' for #<ActiveRecord::Relation:0x2aaaad35d720>
- Escape ''&'' in text_field_with_auto_complete
- R 1.7.0 (Windows) Crashes After using "Install Package from Cran option" within
- Sorting/Ordering Search Results
- OT: ManxPower 2005 European Tour