Do not use instance variables in partial

I am a beginner. When I modified the controller, I didn't know which controller it was connected to, so I will leave it as a memorandum.

ruby:index.html.erb


<%= render 'layout/header' %> #Bad example

ruby:_header.html.erb


<%= @product.name %> #Bad example

Action

ruby:index.html.erb


<%= render 'layout/header', product_name: @product.name %>

ruby:_header.html.erb


<%= product_name %>

That's it! !! !!

Reference

https://qiita.com/mom0tomo/items/e1e3fd29729b2d112a48

It seems that you also use locals:. In that case, add partial: as well.

Recommended Posts

Do not use instance variables in partial
[Java] Do not use "+" in append!
Do not declare variables in List in Java
Use ruby variables in javascript.
Do you use Stream in Java?
[Docker] Use environment variables in Nginx conf
Do not accept System.in in gradle run
Do not return when memoizing in Ruby
How to use environment variables in RubyOnRails
Support for CheckStyle "Do not use inline conditions"
Do not write if (isAdmin == true) code in Java
[Java] [Spring] [Spring Batch] Do not create / use Spring Batch metadata table
Use variables for class and id names in haml
File upload with Spring Boot (do not use Multipart File)
Do not write 〇〇 logic in Rails View (* added later)
In Ruby, methods with? Do not always return true/false.
Use java.time in Jackson
Use Interceptor in Spring
Use OpenCV in Java
Use MouseListener in Processing
Use images in Rails
Use PostgreSQL in Scala
Use PreparedStatement in Java
Do not use floats and doubles to calculate decimal numbers
What to do when Method not found in f: ajax
Convenient use of Map that you do not know unexpectedly
[Development log ⑬] Do not let 0 be entered in the form !!
In order not to confuse the understanding of getters and setters, [Do not use accessors for anything! ]