[LRUG] Rails Question : Matching Share Nested Resources to Controllers
jlsync at gmail.com
Mon Nov 5 07:05:24 PST 2007
resources_controller (+1!) is definitely your friend with dealing with
contextual views for polymorphic controllers.
if both Author and Publisher have a name method then the book show view can
contain something like
<%= link_to enclosing_resource.name, enclosing_resource_path %>
or in rails 2.0 you could do
<%= render :partial => enclosing_resource %>
which would automatically use either authors/_author.html.erb or
On 11/5/07, Craig Webster <craig at xeriom.net> wrote:
> On 5 Nov 2007, at 14:04, Anthony Green wrote:
> > I had a brief glance at this but was concerned it was very naïve
> > about view
> > contexts
> I guess it depends on how different the view should be. In most cases
> I'd say a book should be marked up the same way whether it's through
> an author or through a publisher.
> > "* test for the existence of @user or @forum in the view, and
> > display it
> > differently"
> > don't instill much confidence
> Using enclosing_resource_name, enclosing_resource_path,
> enclosing_resource, resource_path etc will handle most if not all of
> my use cases. I'm not sure I'd ever test for @user / @forum - a post
> should show the title, message, date posted, author, comments whether
> it's displayed in a forum or in the users recent posts list.
> Craig Webster | Lead Developer | skype: craigwebster
> Xeriom Networks | t: 0131 208 3800 | w: http://xeriom.net/
> -- Virtual machines, dedicated servers and colocation --
> Xeriom Networks Limited.
> 94/1 Spring Gardens, Abbeyhill, Edinburgh, Scotland.
> Registered in England and Wales. Company No. 5961686.
> All agreements are made under our standard terms and conditions.
> These can
> be found at http://xeriom.net/terms_and_conditions
> Chat mailing list
> Chat at lists.lrug.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Chat