Answer the question
In order to leave comments, you need to log in
Rails 4.2, ActiveRecord.all, how not to return last element?
class QuestionsController < ApplicationController
def index
@questions = Question.all
@questions.order(:created_at)
end
<%= @questions.each do | question | %>
<%= question.title %><br>
<%= question.text %><br>
<% end %>
<%= link_to "New", new_question_path %>
hello
world
azaza
lalka
[#<Question id: 1, title: "hello ", text: "world", created_at: "2015-02-17 15:28:18", updated_at: "2015-02-17 15:28:18">, #<Question id: 2, title: "azaza", text: "lalka\r\n", created_at: "2015-02-17 15:33:25", updated_at: "2015-02-17 15:33:25">] New
Answer the question
In order to leave comments, you need to log in
<%= @questions.each do | question | %>
Replace with
Equals means that "you need to output the result of this command to the template engine"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question