0

Somewhat new to rails and trying to build something to learn, but having an issue.

I have successfully created one form field that reads from a collection of categories. I generated scaffolding for the categories and two fields catId and name. After plugging in the field everything worked perfectly.

I have tried to replicate this with a different name now (zipCode), but am getting an error saying an undefined method of zipCode when trying to save the event (the form that is being filled out). I'm not understanding why this isn't working as easily as the categories did. I have set up the relationships and the attributes are accessible.

Here is some code.

From the event form:

<%= f.collection_select(:catId, Category.all, :catId, :name) %>
<%= f.collection_select(:zip_id, Zip.all, :zip_id, :zipCode) %>

The zip model:

class Zip < ActiveRecord::Base
 attr_accessible :zipCode, :zip_id
 belongs_to :event
end

The event model:

class Event < ActiveRecord::Base
  attr_accessible :catId, :name, :zipCode, :zip_id
  has_many :categories
  has_many :zips
  end

Thanks!

Edited by Devan_1

2
Contributors
1
Reply
13
Views
4 Years
Discussion Span
Last Post by LastMitch
0

I have tried to replicate this with a different name now (zipCode), but am getting an error saying an undefined method of zipCode when trying to save the event (the form that is being filled out). I'm not understanding why this isn't working as easily as the categories did. I have set up the relationships and the attributes are accessible.

Read this:

http://net.tutsplus.com/tutorials/ruby/ruby-for-newbies-missing-methods/

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.