Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 2 - partials: what does @comment = Comment.new mean?

I am working through a tutorial with the following code:

<h3>New Comment</h3>
   <%= render :partial => @comment = Comment.new,
   :locals => { :button_name => "Create" } %>

I believe that 'render :partial => @comment' works like 'render :partial => "comment", :object => @comment'

Where does ' = Comment.new' fit in? Is it shorthand for :object?

Alan

like image 841
Alan Avatar asked Nov 30 '25 07:11

Alan


1 Answers

In Ruby terms,

@obj = Object.new # returns @obj

So you're rendering a comment partial and creating a new comment object that it can work with at the same time.

like image 55
Aaron Yodaiken Avatar answered Dec 02 '25 20:12

Aaron Yodaiken