# Rails undefined local variable or method

**URL:** https://forum.kirupa.com/t/rails-undefined-local-variable-or-method/634251
**Category:** programming
**Created:** [February 16, 2016, 2:06am UTC](https://forum.kirupa.com/t/rails-undefined-local-variable-or-method/634251 "2016-02-16T02:06:56Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![travis](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/travis/32/13217_2.png) [@travis](https://forum.kirupa.com/u/travis)
#### Post date: [February 16, 2016, 2:06am UTC](https://forum.kirupa.com/t/rails-undefined-local-variable-or-method/634251/1 "2016-02-16T02:06:56Z")

</div>

I have a question very similar to[this one](http://stackoverflow.com/questions/13549967/nomethoderror-undefined-method-foobar-path-when-using-form-for) 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])
  end

  def new
    @professor = Professor.new
  end

```

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?

---

<div class="post-metadata">

### Author: ![krilnon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/krilnon/32/34_2.png) [@krilnon](https://forum.kirupa.com/u/krilnon)
#### Post date: [February 16, 2016, 4:39am UTC](https://forum.kirupa.com/t/rails-undefined-local-variable-or-method/634251/2 "2016-02-16T04:39:14Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![travis](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/travis/32/13217_2.png) [@travis](https://forum.kirupa.com/u/travis)
#### Post date: [February 16, 2016, 1:25pm UTC](https://forum.kirupa.com/t/rails-undefined-local-variable-or-method/634251/3 "2016-02-16T13:25:59Z")

</div>

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.
