Very new to Ruby on Rails and devise. I'm currently trying to fill out a table on an HTML page that should list all the records from the Student table in my database (MYSQL).
<tbody> <% for student in @students %> <tr> <td> <%= student.email %> </td> </tr> <% end %> </tbody>
I also tried @students.each |students|
.
Both variants give the error NoMethodError, undefined method 'each' for nil:NilClass
According to the results of my online search, I am referencing the students table but not declaring it somewhere
def <name> @students = Students.all endAs far as I know, it needs to go somewhere, but I don't know where.
Any suggestions on what to do would be great.
Rails 7.0.3 Design 4.8
You change
Students
toStudent
and useeach
to loopCreate: users_controller.rb
Create folder: views/users/index.html.erb