Render html withouts assets

20 views
Skip to first unread message

Danil Fomichev

unread,
Oct 19, 2013, 8:19:24 AM10/19/13
to rubyonra...@googlegroups.com
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!

Tamara Temple

unread,
Oct 20, 2013, 2:20:48 PM10/20/13
to rubyonra...@googlegroups.com

On Oct 19, 2013, at 7:19 AM, Danil Fomichev <sib...@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

Reply all
Reply to author
Forward
0 new messages