Ruby on Rails Sunday, March 31, 2019

I can create a new record from the model on the right side of a has_many statement Why user the model on the left plus . plus the model on the right plus build The reason I'm asking is because I came across this piece of code below As you can see it's a little primitive placing the seller's name in the auction model instead of leaving it alone and rendering in views from the records in User I'm gonna remove seller_name from the table

   @auction = current_user.auctions.build(params[:auction])
    @auction.seller_name = current_user.name

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/83cebab4-47be-407e-b12b-298cc06459cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment