3

For rendering a partial I can use

render 'partial_name' or render partial: 'partial_name'

I came to know that render is the shorthand syntax of render partial and render will not accept additional local variables for the partial from this SO answer

I would like to know if there is any performance issue when using render instead of render partial

Community
  • 1
  • 1
webster
  • 3,902
  • 6
  • 37
  • 59
  • You should look at both methods in the rails source and report back the source code. We can help you look at the difference but at least provide a little more research... – penner Oct 02 '15 at 17:15

1 Answers1

1

In Rails, the render action

"Renders the content that will be returned to the browser as the response body."

It is possible to render an action, text, the contents of a file, and other things, including a partial view.

render :action => "Create"
render :file => "/path/to/file/foo.erb", :layout => true, :status => 404
render :partial =>...

Using the partial label explicitly, disambiguates the render action for Rails ActionController.

As far as performance, I haven't done the test to confirm, but I think it's reasonable to expect it is more efficient to use render :partial for the above reasons.

When I'm looking for the nuts & bolts underlying Rails logic, this is an excellent detailed technical reference.

Elvn
  • 3,021
  • 1
  • 14
  • 27