I can get an object in the view from the "new" method but cannot get it from another method from controller. Why?
So, I have this in the routes.rb:
Rails.application.routes.draw do
get 'horarios/new'=> 'horarios#new'
get 'horarios/newprofessor'=> 'horarios#newprofessor'
end
And this in the horarios_controller.rb:
class HorariosController < ApplicationController
def new
@horario = Horario.new
@teste = "it prints!"
end
def newprofessor
@teste = "it prints!"
end
end
And put this in both views (new.html.erb and newprofessor.html.erb):
<% raise @teste.inspect %>
The "new" view gives me the object, but the "newprofessor" view says that it's nil. Why is that? Thank you!
Aucun commentaire:
Enregistrer un commentaire