Rails undefined local variable or method

I have a question very similar to this one but that’s a really old post on Stack Overflow so I’m coming here to see if anyone can explain this to me.

My four_for does not work when I have this

<%= form_for (@professor) do |f| %>
   <%= f.label :fname %>
   <%= f.text_field :fname %>

But it works fine when I have:

<%= form_for (:professor) do |f| %>
       <%= f.label :fname %>
       <%= f.text_field :fname %>`

By the way this is my professor controller:

class ProfessorController < ApplicationController
  def show
    @professor = Professor.find(params[:id])

  def new
    @professor = Professor.new

The answer given on Stack Overflow says that it’s because there is no route/action for the professorController, which is understandable, however before I started working on this project I read Michael Hartel’s Ruby on Rails Tutorial and he created a users model without adding a route action other than resources :user (which I have as resources :professor).

Anyone on Kirupa a Rails developer who could lend a hand?

Did you paste the same thing twice or is there some subtle difference between your first and second code blocks?

In the SO post there’s a difference between using a symbol and using an instance property… not sure if that’s what you meant to illustrate in your code too.

Hey sorry about that, yeah I fixed it now. It is a very subtle difference, the first is a variable I have changed the second to a method call.