Answer the question
In order to leave comments, you need to log in
Models in Rails, how to display information?
I want to page localhost:3000/teacher/index, fetch all names from the database
My controller is:
class TeachherController < ApplicationController
def index
@authors = Teacher.all
end
end
And the view is index
<%= @teachers.params %>
Teacher(id : integer, name: string, age: integer, created_at: datetime, updated_at: datetime)
And there are 3 Teachers
(not working)
Answer the question
In order to leave comments, you need to log in
<% @teachers.each do |teacher| %>
<%= teacher.name %>
<% end %>
Dude, this is not the first time you've posted a simple question here. Learn to first formulate a query, then enter it into Google, and then follow the links and read, preferably google in English. There will be more results.
And read rusrails.ru from cover to cover.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question