0
I’m a beginner in Ruby, and I made this mistake...
def new
@section = Section.new({:page_id => @page.id, :name => "Default"})
@pages = @page.subject.pages.sorted
@section_count = Section.count + 1
end
Tell me the problem is on line two, someone can help me?
Apparently,
@page
is not initialized. Boot aputs @page
at the very beginning of the method– Jefferson Quesado
continues to make the same mistake
– Alexandre Seabra
Of course it will give the same error. I am interested in debugging to know what the value of
@page
. He hasn’t printed anything? How are you testing your code?– Jefferson Quesado
did not print anything, I am trying to access the page sections/new from the browser
– Alexandre Seabra
You start the application from a terminal?
– Jefferson Quesado
yes, but also not print anything on the terminal
– Alexandre Seabra
Where would you like to see the information at
@page
? Who fills in this information for you to seek theid
hers?– Jefferson Quesado
If possible, there are more details about the class created by you?
– Jefferson Quesado
Ok, I confirmed here by reading several examples. When you call the
new
, your object is still empty. Therefore,@page
has valuenil
. You need to pass as an argumentnew
something he can start@page
– Jefferson Quesado