Wasi
Wasi

Reputation: 1246

render_to_string from another controller's action.

I used:

render_to_string(:controller=>:controllerName,:action=>:actionName)

but this only gives me the content of header and footer and not the actual content of that specific page.

Is there any other way?

Thanks

Upvotes: 1

Views: 832

Answers (2)

Andrew
Andrew

Reputation: 3670

@var = render_to_string(:template => "controller/action", :layout => false)

Upvotes: 1

Rahul garg
Rahul garg

Reputation: 9362

I have used

@var = render_to_string(:file => "view_folder/index", :layout => false).to_json

to get data from render_to_string, and it works fine..

Upvotes: 1

Related Questions