Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R_C and MimeType::register_alias aliased mime types? #7

Open
jensb opened this issue Mar 15, 2010 · 1 comment
Open

R_C and MimeType::register_alias aliased mime types? #7

jensb opened this issue Mar 15, 2010 · 1 comment

Comments

@jensb
Copy link

jensb commented Mar 15, 2010

Hello,
I have an application that serves two different template sets depending on the URL it is called with. For this purpose I have (in config/initializers/mime_types.rb)

Mime::Type.register_alias "text/html", :iframe

and (in application_controller.rb)

before_filter :adjust_format
def adjust_format
  request.format = :iframe  if request.subdomains.first == "iframe" and request.format == :html
end

This works fine

  • with non-R_C controllers and no explicit "respond_to" block,
  • with R_C controllers and no explicit "wants.html" block,
  • with R_C controllers and a duplicated "wants.html" block as "wants.iframe".

But this is hardly DRY. How can I make R_C recognize the registered MIME type aliases, so that (in my case) it sees that the :iframe format is just an alias for :html, and uses the "wants.html" block but renders the :iframe template if "request.format==:iframe"?

Thank you!

@jensb
Copy link
Author

jensb commented Mar 15, 2010

Update: it seems that just doubling the wants.html blocks as "wants.iframe" is not enough - then I get "TemplateMissing" exceptions, even when all templates are there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant