Forum: Ruby on Rails Render html withouts assets

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B0ecdd8fcdaa8880838e1f4a983e2b7f?d=identicon&s=25 Danil Fomichev (Guest)
on 2013-10-20 19:42
(Received via mailing list)
Hi,

Is there a way to render template without  assets from application.js
and
application.css?

In my project I use html rendered by controllers. This data is received
by
ajax and added to current page interactively.  The problem is that html
contains unnecessary data with js and css files. I need only HTML from
the
view template.


Thanks!
Aa082c8b00a50928e5860dcd70bf2368?d=identicon&s=25 tamouse m. (tamouse_m)
on 2013-10-20 20:22
(Received via mailing list)
On Oct 19, 2013, at 7:19 AM, Danil Fomichev <siblynx@gmail.com> wrote:

> Hi,
>
> Is there a way to render template without  assets from application.js and
application.css?

You can specify a different layout that does not include these, or

>
> In my project I use html rendered by controllers. This data is received by ajax
and added to current page interactively.  The problem is that html contains
unnecessary data with js and css files. I need only HTML from the view template.


If this is just a chunk of html, not a complete document, then you can
render with no layout at all. In your controller, do:


class MyApiController < ApplicationController
  layout false

  .

end

Then there will be no layout for that entire controller.

See http://edgeguides.rubyonrails.org/layouts_and_rendering.html
This topic is locked and can not be replied to.