0
내 생각에는 이야기/_form.slim에서 예외가 발생합니다.현재 액세스되지 않는 모델 특성에 대한 뷰에서 SQL 예외가 throw됩니다.
...
= 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}'."
...
모델/이야기 :
SQLite3::SQLException: no such column: constraints.sentence_id: SELECT "constraints".* FROM "constraints" WHERE "constraints"."sentence_id" = 1 LIMIT 1
기분을 상하게하는 줄 이야기/_form.slim 2 번째 라인이다 : 그것은 내가 액세스를 시도하고 있지 않다 속성에 대해 불평 있기 때문에 예외가 이상한 것 같다. 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
모델/sentence.rb :
class Sentence < ActiveRecord::Base
belongs_to :story
has_one :constraint
accepts_nested_attributes_for :constraint
end
모델/constraint.rb :
class Constraint < ActiveRecord::Base
has_many :sentences
end
dB/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
어떤 아이디어? 그것을 알아 내려고 내 소리를 찢어지고있다 :)
감사합니다. 잘 했어. –