In RoR, I sometimes see:
render @users
or
render 'new'
How are the two different?
In short, render @users
is rendering a collection of objects of type User
with a partial file named _user.html.erb
, and render 'new'
is rendering the new
action & is equivalent to render :action => new
.
Best to review the Layouts and Rendering in Rails page in the Ruby on Rails Guides to understand how these two work & where they can be used appropriately, and the various in-built assumptions that make these and many other convenient render
methods possible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With