0
私はこのシステムをほぼ3年間維持しており、システムはレールを使用しています。1.2.6 モデルに新しい属性を追加するときに問題があります。私はモデルエラーのための未定義のメソッドを取得します。未定義のモデル
これは前回はうまくいきましたが、今回はコンソールで実行しても問題は解決できませんでした。
has_many:through relationshipという3つのモデルを作成しました。私は移行をよく理解していないので、私は常に手動でテーブルを作成しています。
Undefined method 'spucats=' for #<Casedf:....>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/base.rb:1860:in `method_missing'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/base.rb:1675:in `send'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/base.rb:1675:in `attributes='
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/base.rb:1674:in `each'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/base.rb:1674:in `attributes='
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/base.rb:1508:in `initialize_without_callbacks'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/callbacks.rb:225:in `initialize'
/home/jaz/dfp/app/controllers/casedf_controller.rb:89:in `new'
/home/jaz/dfp/app/controllers/casedf_controller.rb:89:in `createcase'
/usr/bin/mongrel_rails:19:in `load'
/usr/bin/mongrel_rails:19
がポイント何かを助けてください:
class Casedf < ActiveRecord::Base
has_many :casespus
has_many :spucats, :through => :casespus
end
class Spucat < ActiveRecord::Base
has_many :casedfs, :through => :casespus
has_many :casespus
end
class Casespu < ActiveRecord::Base
belongs_to :casedf
belongs_to :spucat
end
私new.rhtmlは
<td>Category<img src="/main/images/asterick1.gif" height="10" width="10" alt=""></td>
<td>:</td>
<td><select name="case[spucats][]" multiple>
<option value="" selected="selected">Please Select</option>
<% @spus.each do |category|%>
<option value="<%= category.id%>">
<%= category.name%> </option>
<%end%>
</select>
</td>
私は新しいCasedfを作成しようとしました、私はこのエラーを取得します。私は数週間これを見てきました。
ここでモデルを誤って入力したと仮定します。私の賭けは問題である "マニュアルテーブルの作成"にあります... –
はい真、不完全なコードとtypos.sorry.yillの多くが正しい 'em – janida
marc:マニュアルテーブルの作成?しかし、私がスクリプト/コンソールを実行すると、カスケードがうまく作成されました。私は他の人のために手動で行った。しかし、彼らはすべて細かいことが分かった。 – janida