Hi, I was wondering if it is possible to make a route dynamic. I am working with components and want to be able to call the component with a different leading in path, or even from a sub domain. I was trying map.connect ''path/:cnt/:action/:id'', :controller => ''otherpath/:cnt'' But was unsuccessful. The only other way I can think of is mapping each controller, eg, map.connect ''path/controller/:action/:id'', :controller => ''otherpath/controller'' Regards, Dylan.
Dylan Egan wrote:>I am working with components and want to be able to call the component >with a different leading in path, or even from a sub domain. > >I was trying map.connect ''path/:cnt/:action/:id'', :controller => >''otherpath/:cnt'' >There is an old patch on Trac regarding controller prefixes. That might be what you are looking for. If so, I provide an updated version of the patch...
Hi Nicholas, I found the patch on Trac and would be interested in an updated version. Dylan.
patrick.fernie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2005-Jul-06 19:28 UTC
Validation Question
Quick, possibly obvious, question about working with validation and Single Table Inheritance. My STI seems to be working fine, but is leading me to a problem with validations. For example, from the Beta Book: class Person < ActiveRecord::Base validates_uniqueness_of :login end class Customer < Person end class Employee < Person end class Manager < Employee end As you can see, I''ve added validation that makes sure that all records in the persons table have unique login names. However, if I were to do: Manager.create(:login=>"pgf") and then do: Manager.create(:login=>"pgf"), there is obviously an error. However: Customer.create(:login=>"pgf") generates no error. This makes sense, since the Customer class is (presumably) only checking records that have type="Customer", so it doesn''t see the Manager with the same login. So, my question becomes, is there a way to ensure that validations check all rows in the table, not just for the current class? Or am I forced to add a validation step that does something with a Person.find_all within each subclass? I guess what I''m getting at is that if I specify a validation in the Person class, I want it to validate even subclasses in the same "context", i.e. within all Person rows. -Patrick