uninitialized constant ActionView::CompiledTemplates::Category
Asked Answered
K

4

10

using this tutorial

http://railscasts.com/episodes/57-create-model-through-text-field

need to make it work in my app, was on rails 3.0.7 and it worked fine, updated it to 3.1.3 and I got this error now

uninitialized constant ActionView::CompiledTemplates::Category

I would look for answers more time but now I am really short on time. I have looked into most part of google results related to this problem and no good. Need help please.

form

<%= f.collection_select :category_id, Category.find(:all), :id, :name, :prompt => "Select a Category" %>
or create one:
<%= f.text_field :new_category_name %>

model

class Tvstation < ActiveRecord::Base
  belongs_to :category
  attr_accessor :new_category_name
  before_save :create_category_from_name

  def create_category_from_name
    create_category(:name => new_category_name) unless new_category_name.blank?
  end
end
Karttikeya answered 14/5, 2012 at 18:11 Comment(0)
K
28

ok, just for others if they will get into this stupid things as I did, don't forget to have the category.rb in the app/models..

class Category < ActiveRecord::Base
  ...
end
Karttikeya answered 14/5, 2012 at 18:22 Comment(0)
K
3

For me, i got the similar problem in the views. My Category model is available inside namespace example

Module Financial
  class Category
  end
end

When i call simply Category.get_method. It was giving same error. so that i modified into Financial::Category that solved my problem.

Knighterrantry answered 30/9, 2015 at 13:33 Comment(0)
A
0

I was using a PORO and it wasn't loading, giving me this error. It was because I had changed the class name without changing the file name.

Arthromere answered 6/2, 2018 at 6:17 Comment(0)
C
0

How the others suggested I had a similar problem solved be fix of wrong model name.

Chuckwalla answered 26/7, 2018 at 18:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.