Hello,
How does the “render :partial => ‘/comment/form’,
:collection=>@blog.comments” work? What object does this pass to the
partial view? How do I access the comment object in partial view?
Hello,
How does the “render :partial => ‘/comment/form’,
:collection=>@blog.comments” work? What object does this pass to the
partial view? How do I access the comment object in partial view?
On 25 November 2010 11:59, Vineeth P. [email protected] wrote:
Hello,
How does the “render :partial => ‘/comment/form’,
:collection=>@blog.comments” work? What object does this pass to the
partial view? How do I access the comment object in partial view?
Have a look at the Rails Guide on Layouts and Rendering. It should
get you started at least.
Colin
Yes, you would better read about that.
But I will answer, in partial you would be able to access to the item by
accessing variable named by the name of the partial, in your case “form”
On Thu, Nov 25, 2010 at 2:03 PM, Colin L. [email protected]
wrote:
Colin
–
С уважением,
Виталий Янчук
http://www.vitalik.com.ua/
hey Vineeth,
As mentioned by others about understand the concept of partial first
thats
true.
But the collection object can be accessable by the name of partial in
you
case you can access using “<%= form.attribute_name %>”
<%= “render :partial => ‘/comment/form’, :collection=>@blog.comments” %>
But if in-case you don’t want the object name “form” then you can parse
“as
=> object_name” while calling partial. there are few more options like
“form_counter” etc if you want to display it.
Thanks
Abhis
“Виталий Янчук” [email protected] wrote in post #963883:
Yes, you would better read about that.
But I will answer, in partial you would be able to access to the item by
accessing variable named by the name of the partial, in your case “form”On Thu, Nov 25, 2010 at 2:03 PM, Colin L. [email protected]
wrote:Colin
–
С уважением,Виталий Янчук
http://www.vitalik.com.ua/
Thank you!
Abhishek shukla wrote in post #964036:
hey Vineeth,
As mentioned by others about understand the concept of partial first
thats
true.But the collection object can be accessable by the name of partial in
you
case you can access using “<%= form.attribute_name %>”
<%= “render :partial => ‘/comment/form’, :collection=>@blog.comments” %>But if in-case you don’t want the object name “form” then you can parse
“as
=> object_name” while calling partial. there are few more options like
“form_counter” etc if you want to display it.Thanks
Abhis
Thanks, that’s quite a lot of useful information.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs