When should I use “:object =>” or “:collection =>” to pass an object
reference to a partial vs reference an instance variable directly with
the partial?
I would value best practice/opinions/pros/cons on this.
When should I use “:object =>” or “:collection =>” to pass an object
reference to a partial vs reference an instance variable directly with
the partial?
I would value best practice/opinions/pros/cons on this.
I use collection to loop through a list. So, render :partial =>
‘comment’, :collection => @comments saves me a few lines of code over
putting a loop inside the view or partial. :object would be useful
when showing just a single record. So, maybe something like this
makes sense:
This gives me a post, a partial for its author, and a partial for each
comment.
Cheers
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