I had this working with the tutorial "users" and "microposts".. now trying with my new app. Im trying to run the following code snippet in my view, cascading from one object to another. Error comes up indicating job_sub_category is not a method. undefined method `job_sub_category' for #<JobCategory:0x57a3ab8>
<% @job_categories.each do |job_category| %>
<td><%= job_category.name %></td>
<td><%= job_category.job_sub_category.name %></td>
I ran a job_categories.method.sort routine and sure enough, there was no link to the sub objects... There was no job... method of any kind... Here is how I defined the models for each object, noting that I do have the has_many in the JobCategory class.
class JobCategory < ActiveRecord::Base
has_many :jobsubcategories, dependent: :destroy
class JobSubCategory < ActiveRecord::Base
Any ideas on what im missing? Curious although I thought I was thorough in my spelling and pluralization.. Although it may make sense, its very frustrating how my Class file name is job_category, then reals eliminates the underscores to create a class JobCategory and JobSubCategory, then I have to pluralize the relationship object name in the "has_many", and then when using the objects in my view I have to go back and use the names with underscores in them. Oh well, perhaps I still have some name issue.. but its definitely not in the list of methods when running job_category.method (also for fun tried job_sub_category.method and as I expected there was no relationship method back to job_category).... I'd appreciate another set of eyes.. thanks in advance, Jay.