My Controller:
class RoomsController < ApplicationController
before_action :set_room, only: [:show, :edit, :update, :destroy]
def nome_completo
"#{title}, #{location}"
end
# GET /rooms
# GET /rooms.json
def index
@rooms = Room.all
end
# GET /rooms/1
# GET /rooms/1.json
def show
end
# GET /rooms/new
def new
@room = Room.new
end
# GET /rooms/1/edit
def edit
end
......
end
My View:
<h1>Quartos recém postados</h1>
<ul>
<% @rooms.each do |room| %>
<li><%= link_to room.nome_completo , room %></li>
<% end %>
</ul>
The displayed error: undefined method 'full_name' for #Room: 0x0000000ed6d478
As you can see the method is already defined in the controller, and my view is able to call various methods of the Room controller except the ones I defined.