このチュートリアルを使用する
http://railscasts.com/episodes/57-create-model-through-text-field
私のアプリで動作させる必要があり、Rails 3.0.7上にあり、正常に動作し、3.1.3に更新しましたが、このエラーが発生しました
uninitialized constant ActionView::CompiledTemplates::Category
もっと時間をかけて答えを探したいのですが、今は本当に時間が足りません。私はこの問題に関連するグーグルの結果の大部分を調べましたが、良くありません。助けが必要です。
形
<%= 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