未初始化的常量 ActionView::CompiledTemplates::Category [英] uninitialized constant ActionView::CompiledTemplates::Category
本文介绍了未初始化的常量 ActionView::CompiledTemplates::Category的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用本教程
http://railscasts.com/episodes/57-create-模型到文本字段
需要让它在我的应用程序中运行,在 Rails 3.0.7 上运行良好,将其更新到 3.1.3,我现在收到此错误
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.
表格
<%= f.collection_select :category_id, Category.find(:all), :id, :name, :prompt => "Select a Category" %>
or create one:
<%= f.text_field :new_category_name %>
模型
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
推荐答案
好的,对于其他人来说,如果他们会像我一样陷入这种愚蠢的事情,请不要忘记在 app/models 中包含 category.rb..
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
这篇关于未初始化的常量 ActionView::CompiledTemplates::Category的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文