Undefined method 'state'

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.

This gives undefined method join error:

form_for @student do |f| f.collection_select(:student_fail_attribute,
StudentFailState.all, :id, :key) end

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
[email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs