# Undefined method 'state'

**URL:** <https://www.ruby-forum.com/t/undefined-method-state/183251>\
**Category:** Rails\
**Created:** [February 10, 2010, 5:59pm UTC](https://www.ruby-forum.com/t/undefined-method-state/183251 "2010-02-10T17:59:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [February 10, 2010, 5:59pm UTC](https://www.ruby-forum.com/t/undefined-method-state/183251/1 "2010-02-10T17:59:17Z")

</div>

I can’t imagine what I’m trying to do is complicated at all in Rails.  
Yet, I am now getting this error: undefined method `state’ for  
:StudentFailState:Symbol.

student.rb  
has\_one :student\_fail  
attr\_accessor :student\_fail\_attribute

#controller  
def student\_fail  
@student = @student.find params[:id]

def update\_student\_fail  
@student.build\_student\_fail params[:student][:student\_fail\_attribute]  
if @student.save

#view  
form\_for @student do |f| f.collection\_select(  
:student\_fail\_attribute, params[:StudentFailState.state], params[:id],  
params[:key]) end

true is an attribute of the StudentFailState table. There are three  
records in that table. So in the dropdown it will display the text (key  
attribute) of each table and each table will have an id.

Any suggestions? Thanks.

---

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [February 10, 2010, 6:06pm UTC](https://www.ruby-forum.com/t/undefined-method-state/183251/2 "2010-02-10T18:06:40Z")

</div>

This gives undefined method join error:

form\_for @student do |f| f.collection\_select(:student\_fail\_attribute,  
StudentFailState.all, :id, :key) end

---

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [February 10, 2010, 6:15pm UTC](https://www.ruby-forum.com/t/undefined-method-state/183251/3 "2010-02-10T18:15:32Z")

</div>

John M. wrote:

> I can’t imagine what I’m trying to do is complicated at all in Rails.  
> Yet, I am now getting this error: undefined method `state’ for  
> :StudentFailState:Symbol.
> 
> student.rb  
> has\_one :student\_fail  
> attr\_accessor :student\_fail\_attribute
> 
> #controller  
> def student\_fail  
> @student = @student.find params[:id]
> 
> def update\_student\_fail  
> @student.build\_student\_fail params[:student][:student\_fail\_attribute]  
> if @student.save
> 
> #view  
> form\_for @student do |f| f.collection\_select(  
> :student\_fail\_attribute, params[:StudentFailState.state], params[:id],  
> params[:key]) end
> 
> true is an attribute of the StudentFailState table. There are three  
> records in that table. So in the dropdown it will display the text (key  
> attribute) of each table and each table will have an id.
> 
> Any suggestions? Thanks.

Yes. Put Rails aside for a few days and focus on learning Ruby. You’re  
making an elementary syntax error. If you can’t see it, then you don’t  
yet know Ruby well enough to use Rails profitably.

Best,  
–Â  
Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
