私のビュー、storys/_form.slim で次の例外が発生しています。アクセスしようとしていない属性について不平を言っているため、例外は奇妙に思えます。
SQLite3::SQLException: no such column: constraints.sentence_id: SELECT "constraints".* FROM "constraints" WHERE "constraints"."sentence_id" = 1 LIMIT 1
問題のある行は、storys/_form.slim の 2 行目です。
...
= form_tag("/stories/#{@story.id}", :method => "put") do
= label_tag "Type the next line in the story. You must use the word '#{@story.curr_sentence.constraint.phrase}'."
...
models/story.rb:
class Story < ActiveRecord::Base
has_many :sentences, :dependent => :destroy
accepts_nested_attributes_for :sentences, :allow_destroy => true
def curr_sentence
self.sentences.find_by_turn(self.turn)
end
...
end
models/sentence.rb:
class Sentence < ActiveRecord::Base
belongs_to :story
has_one :constraint
accepts_nested_attributes_for :constraint
end
models/constraint.rb:
class Constraint < ActiveRecord::Base
has_many :sentences
end
デシベル/schema.rb:
create_table "stories", :force => true do |t|
t.integer "turn", :default => 1
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "sentences", :force => true do |t|
t.integer "constraint_id"
t.integer "story_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "constraints", :force => true do |t|
t.string "phrase"
t.integer "constraint_category_id", :limit => 255
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
何か案は?それを理解しようとして私の耳を引き裂いています:)