Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Question about Rails 2.x behavior
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  10 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Yehuda Katz  
View profile  
 More options Aug 8 2009, 11:19 pm
From: Yehuda Katz <wyc...@gmail.com>
Date: Sun, 09 Aug 2009 00:19:12 -0300
Local: Sat, Aug 8 2009 11:19 pm
Subject: Question about Rails 2.x behavior
In Rails 2.x, if you have an XML template, and try to render a template
that does not have an XML version, but does have an HTML version, it
will be rendered. XML and HTML are just examples; this is true for any
two mime types.

Is this behavior important? First of all, I'm not sure this is the right
behavior, since it's possible to be explicit about the format you wish
to use and rendering a template from a different MIME seems likely to be
a mistake. Second of all, it requires us to widen our search criteria
when looking for subsidiary templates (like partials), and prevents us
from efficiently caching the template for a given format (instead, we
need to cache the template for a given Array of formats, which is much
less efficient).

I also think that restricting subsidiary templates would be consistent
with other (non-breaking) fixes we've done to ensure that layouts match
the MIME type of the template they are wrapping (which allowed us to
eliminate the exempt_from_layout hacks).

Thanks for your attention,

-- Yehuda


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeremy McAnally  
View profile  
 More options Aug 9 2009, 12:14 am
From: Jeremy McAnally <jeremymcana...@gmail.com>
Date: Sat, 8 Aug 2009 21:14:25 -0700 (PDT)
Local: Sun, Aug 9 2009 12:14 am
Subject: Re: Question about Rails 2.x behavior
Yeah I definitely agree that this should change.  It's actually bitten
me a couple of times where I, when writing my initial tests, would
forget to write the XML view, but the test still passed because it
rendered the HTML template.  Bad Rails!  Bad!

Would love to see this implemented to be more strict.

--Jeremy

On Aug 8, 10:19 pm, Yehuda Katz <wyc...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Luke Melia  
View profile  
 More options Aug 9 2009, 12:41 am
From: Luke Melia <l...@lukemelia.com>
Date: Sat, 8 Aug 2009 21:41:25 -0700 (PDT)
Local: Sun, Aug 9 2009 12:41 am
Subject: Re: Question about Rails 2.x behavior
I've always thought this behavior to be strange and would not miss it.
-Luke

On Aug 8, 11:19 pm, Yehuda Katz <wyc...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Turner  
View profile  
 More options Aug 9 2009, 1:11 am
From: Mark Turner <m...@amerine.net>
Date: Sat, 8 Aug 2009 22:11:41 -0700 (PDT)
Local: Sun, Aug 9 2009 1:11 am
Subject: Re: Question about Rails 2.x behavior
On Aug 8, 8:19 pm, Yehuda Katz <wyc...@gmail.com> wrote:

> In Rails 2.x, if you have an XML template, and try to render a template
> that does not have an XML version, but does have an HTML version, it
> will be rendered. XML and HTML are just examples; this is true for any
> two mime types.

> Is this behavior important? First of all, I'm not sure this is the right
> behavior, since it's possible to be explicit about the format you wish
> to use and rendering a template from a different MIME seems likely to be
> a mistake. Second of all, it requires us to widen our search criteria
> when looking for subsidiary templates (like partials), and prevents us
> from efficiently caching the template for a given format (instead, we
> need to cache the template for a given Array of formats, which is much
> less efficient).

I fully agree.

> I also think that restricting subsidiary templates would be consistent
> with other (non-breaking) fixes we've done to ensure that layouts match
> the MIME type of the template they are wrapping (which allowed us to
> eliminate the exempt_from_layout hacks).

Its a change that should happen, we should be explicit of the mime
types and our templates.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Koziarski  
View profile  
 More options Aug 9 2009, 1:46 am
From: Michael Koziarski <mich...@koziarski.com>
Date: Sun, 9 Aug 2009 17:46:23 +1200
Local: Sun, Aug 9 2009 1:46 am
Subject: Re: [Rails-core] Question about Rails 2.x behavior

> In Rails 2.x, if you have an XML template, and try to render a template
> that does not have an XML version, but does have an HTML version, it
> will be rendered. XML and HTML are just examples; this is true for any
> two mime types.

I'm guessing that the historical basis for this behaviour is:

xml.content render :partial=>"post", :object=>post

So long as we support :format=>:html in that call, I think the change
is worth making in 3.0. I'd also suggest that the exception gave a
useful message like:

Template not found: post.xml, found post.html.  If that's what you
wanted use render ... :format=>:html

--
Cheers

Koz


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matt Jones  
View profile  
 More options Aug 9 2009, 2:04 am
From: Matt Jones <al2o...@gmail.com>
Date: Sun, 9 Aug 2009 02:04:19 -0400
Local: Sun, Aug 9 2009 2:04 am
Subject: Re: [Rails-core] Re: Question about Rails 2.x behavior

On Aug 9, 2009, at 1:46 AM, Michael Koziarski wrote:

I'd also assume the behavior might be left over from the early days of  
bare .erb templates - there are still a few of those in the test  
suite, and I remember it was a headache when sorting out the 'JS  
responses get wrapped in HTML layouts' mess.

--Matt Jones


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mislav Marohnić  
View profile  
 More options Aug 9 2009, 6:42 am
From: Mislav Marohnić <mislav.maroh...@gmail.com>
Date: Sun, 9 Aug 2009 12:42:06 +0200
Local: Sun, Aug 9 2009 6:42 am
Subject: Re: [Rails-core] Question about Rails 2.x behavior

On Sun, Aug 9, 2009 at 05:19, Yehuda Katz <wyc...@gmail.com> wrote:

> In Rails 2.x, if you have an XML template, and try to render a template
> that does not have an XML version, but does have an HTML version, ...

Am I the only one that didn't understand this first sentence?

How can you *have* an XML template if that template *doesn't* have an XML *
version*?

Anyway, I'd like to chip in with a small request (I don't know if it's
exactly related to the question) — if you defined extra HTML formats (using
Mime::Type.register_alias) in your app (like :mobile and :iphone), I'd like
that templates render the other HTML format if the current one isn't
available. This is especially useful for partials; index.mobile.erb and
index.iphone.erb should both be able to use the _post.html.erb partial.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kieran P  
View profile  
 More options Aug 9 2009, 12:53 am
From: Kieran P <kieran...@gmail.com>
Date: Sat, 8 Aug 2009 21:53:00 -0700 (PDT)
Subject: Re: Question about Rails 2.x behavior
Hey,

Yes, it should assume a file of the same type, and raise if there
isn't.

i.e.

index.html.erb  renders  'example'  , should find example.html.erb or
raise

Same with xml:

index.xml.erb  renders  'example' , should find example.xml.erb or
raise

But overwrites should be allowed:

index.html.erb  renders  'example.xml.erb' , should work

Regards
Kieran

On Aug 9, 3:19 pm, Yehuda Katz <wyc...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yehuda Katz  
View profile  
 More options Aug 9 2009, 8:06 am
From: Yehuda Katz <wyc...@gmail.com>
Date: Sun, 09 Aug 2009 09:06:14 -0300
Local: Sun, Aug 9 2009 8:06 am
Subject: Re: [Rails-core] Re: Question about Rails 2.x behavior

render "example.xml" would work just fine today on master, even with the
change I'm proposing.

-- Yehuda


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yehuda Katz  
View profile  
 More options Aug 9 2009, 8:08 am
From: Yehuda Katz <wyc...@gmail.com>
Date: Sun, 09 Aug 2009 09:08:14 -0300
Local: Sun, Aug 9 2009 8:08 am
Subject: Re: [Rails-core] Re: Question about Rails 2.x behavior

This is actually rather similar to the requirement that RJS templates
also be able to render HTML. Essentially, you want to be able to have an
alias mime that expands out into several acceptable format extensions.
Solution forthcoming :)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »