# "Undefined Attribute Method"

**URL:** <https://discuss.rubyonrails.org/t/undefined-attribute-method/58104>\
**Category:** rubyonrails-talk\
**Created:** [March 26, 2011, 4:56pm UTC](https://discuss.rubyonrails.org/t/undefined-attribute-method/58104 "2011-03-26T16:56:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mistral\_Contrastin](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@Mistral\_Contrastin](https://discuss.rubyonrails.org/u/Mistral_Contrastin)\
**Post date:** [March 26, 2011, 4:56pm UTC](https://discuss.rubyonrails.org/t/undefined-attribute-method/58104/1 "2011-03-26T16:56:27Z")

</div>

I couldn't find any other source to solve my problem, so I'm posting here I have a controller "candidates"

class CandidatesController \< ApplicationController &nbsp;&nbsp;def new &nbsp;&nbsp;&nbsp;&nbsp;@candidate = Candidate.new &nbsp;&nbsp;end end

A table model called candidate with lots of validations.

I create my new.html.erb and whenever I try to open it I get this error message:

undefined method `define\_attribute\_methods' for nil:NilClass

Extracted source (around line #3):

1: \<h1\>Yeni Basvuru\</h1\> 2: 3: \<% form\_for @candidate do |t|%\> 4: \<div\> 5: \<%= t.label :name,"Isim"%\> 6: \<%= t.text\_field :name%\>

Please help me out!

---

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [March 26, 2011, 5:49pm UTC](https://discuss.rubyonrails.org/t/undefined-attribute-method/58104/2 "2011-03-26T17:49:27Z")

</div>

> I couldn't find any other source to solve my problem, so I'm posting here I have a controller "candidates"
> 
> class CandidatesController \< ApplicationController def new @candidate = Candidate.new end end
> 
> A table model called candidate with lots of validations.
> 
> I create my new.html.erb and whenever I try to open it I get this error message:

I'd say that the most likely problem is that you've managed to define a method (or have an attribute with a name) that clashes with a standard ruby or activerecord method. Do you have a method or column named class by any chance?

Fred

---

<div class="post-metadata">

**Author:** ![Mistral\_Contrastin](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@Mistral\_Contrastin](https://discuss.rubyonrails.org/u/Mistral_Contrastin)\
**Post date:** [March 26, 2011, 5:56pm UTC](https://discuss.rubyonrails.org/t/undefined-attribute-method/58104/3 "2011-03-26T17:56:51Z")

</div>

> I'd say that the most likely problem is that you've managed to define a method (or have an attribute with a name) that clashes with a standard ruby or activerecord method. Do you have a method or column named class by any chance?
> 
> Fred

I have these:

&nbsp;&nbsp;&nbsp;&nbsp;t.string "name" &nbsp;&nbsp;&nbsp;&nbsp;t.string "surname" &nbsp;&nbsp;&nbsp;&nbsp;t.string "email" &nbsp;&nbsp;&nbsp;&nbsp;t.integer "tc\_id" &nbsp;&nbsp;&nbsp;&nbsp;t.datetime "birthday" &nbsp;&nbsp;&nbsp;&nbsp;t.integer "cellphone" &nbsp;&nbsp;&nbsp;&nbsp;t.integer "localphone" &nbsp;&nbsp;&nbsp;&nbsp;t.boolean "gender" &nbsp;&nbsp;&nbsp;&nbsp;t.string "school" &nbsp;&nbsp;&nbsp;&nbsp;t.string "class" &nbsp;&nbsp;&nbsp;&nbsp;t.text "address" &nbsp;&nbsp;&nbsp;&nbsp;t.boolean "accommodation" &nbsp;&nbsp;&nbsp;&nbsp;t.boolean "scholarship" &nbsp;&nbsp;&nbsp;&nbsp;t.text "other" &nbsp;&nbsp;&nbsp;&nbsp;t.text "arrival" &nbsp;&nbsp;&nbsp;&nbsp;t.text "condition" &nbsp;&nbsp;&nbsp;&nbsp;t.text "reference" &nbsp;&nbsp;&nbsp;&nbsp;t.string "parent\_n" &nbsp;&nbsp;&nbsp;&nbsp;t.string "parent\_s" &nbsp;&nbsp;&nbsp;&nbsp;t.integer "parent\_p" &nbsp;&nbsp;&nbsp;&nbsp;t.string "parent\_e" &nbsp;&nbsp;&nbsp;&nbsp;t.string "alt\_name" &nbsp;&nbsp;&nbsp;&nbsp;t.integer "alt\_phone" &nbsp;&nbsp;&nbsp;&nbsp;t.boolean "attendance" &nbsp;&nbsp;&nbsp;&nbsp;t.string "which\_event" &nbsp;&nbsp;&nbsp;&nbsp;t.boolean "attendance\_p" &nbsp;&nbsp;&nbsp;&nbsp;t.string "which\_camp" &nbsp;&nbsp;&nbsp;&nbsp;t.text "expectation" &nbsp;&nbsp;&nbsp;&nbsp;t.string "source" &nbsp;&nbsp;&nbsp;&nbsp;t.boolean "terms" &nbsp;&nbsp;&nbsp;&nbsp;t.datetime "created\_at" &nbsp;&nbsp;&nbsp;&nbsp;t.datetime "updated\_at"

---

<div class="post-metadata">

**Author:** ![Chris\_Kottom1](https://avatars.discourse-cdn.com/v4/letter/c/c77e96/32.png) [@Chris\_Kottom1](https://discuss.rubyonrails.org/u/Chris_Kottom1)\
**Post date:** [March 26, 2011, 6:07pm UTC](https://discuss.rubyonrails.org/t/undefined-attribute-method/58104/4 "2011-03-26T18:07:02Z")

</div>

That “class” attribute is probably your problem.

---

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [March 26, 2011, 6:12pm UTC](https://discuss.rubyonrails.org/t/undefined-attribute-method/58104/5 "2011-03-26T18:12:46Z")

</div>

> \> I'd say that the most likely problem is that you've managed to define \> a method (or have an attribute with a name) that clashes with a \> standard ruby or activerecord method. \> Do you have a method or column named class by any chance?
> 
> I have these:
> 
> ```
> t\.string &quot;school&quot;
> t\.string &quot;class&quot;
> 
> ```

That would be a yes then.

Fred

---

<div class="post-metadata">

**Author:** ![Mistral\_Contrastin](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@Mistral\_Contrastin](https://discuss.rubyonrails.org/u/Mistral_Contrastin)\
**Post date:** [March 26, 2011, 6:15pm UTC](https://discuss.rubyonrails.org/t/undefined-attribute-method/58104/6 "2011-03-26T18:15:05Z")

</div>

Thanks a lot Fred!!
