myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [myexperiment-hackers] Route issue with "aliased" models


From: Don Cruickshank
Subject: Re: [myexperiment-hackers] Route issue with "aliased" models
Date: Fri, 2 Dec 2011 11:21:15 +0000

I think that this a good idea.  It will simplify the code in quite a few places!

Don.

> -----Original Message-----
> From: address@hidden
> [mailto:address@hidden
> On Behalf Of Finn Bacall
> Sent: 02 December 2011 10:34 AM
> To: address@hidden
> Subject: [myexperiment-hackers] Route issue with "aliased" models
> 
> I've decided to rewrite some code in my datasets branch to take advantage
> of Rails 2's ability to automatically infer routes from a given object (for
> example 'link_to(@object.name, @object')).
> 
> However, it can't figure out what to do with instances of Blob and Network
> as, the resources described in the routes file are named "Files"
> and "Groups" respectively.
> 
> To solve this, rather than having: "resources :files, :controller => 
> :blobs..."
>   you can use: "resources :blobs, :as => :files..."
> 
> which would maintain the same functionality/URL paths as the one above,
> and Rails would know that its the route for the "Blob" model.
> 
> This has the advantage of allowing things that deal with heterogeneous sets
> of resources to be able to generate links to resources without needing switch
> statements.
> 
> The major issue is, all instances of "file_path(@file.id)" etc. would have to 
> be
> replaced with "blob_path(@file.id)". As far as I can tell, there isn't a way 
> to
> avoid this.
> 
> I'd like to hear peoples' thoughts on this.
> 
> -Finn
> 
> --
> Finn Bacall
> School of Computer Science
> University of Manchester
> 
> 
> _______________________________________________
> myexperiment-hackers mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/myexperiment-hackers



reply via email to

[Prev in Thread] Current Thread [Next in Thread]