我的一個模型表(事件)在schema.rb文件,並在其位置上有沒有顯示是這樣的消息 -Rails的遷移錯誤 - 表中schema.rb沒有顯示
# Could not dump table "events" because of following NoMethodError
# undefined method `[]' for nil:NilClass
最後遷移這是成功的結果如下 -
class RemoveOrganiserDescriptionFromEvents < ActiveRecord::Migration
def change
remove_column :events, :organiser_description, :text
end
end
哪些改變這個 -
class AddOrganiserProfileToEvents < ActiveRecord::Migration
def change
add_column :events, :organiser_profile, :url
end
end
我敢肯定它走了「禾nky',因爲該屬性不應該是一個url,它應該是一個字符串。但是,當我嘗試執行其他遷移時,它不起作用。我得到了我的終端以下錯誤,當我嘗試進行耙分貝:遷移 -
未定義的方法to_sym' for nil:NilClass Did you mean? to_s/Users/Michael/MWCoding/MamaKnows/mama_knows/db/migrate/20160415123947_remove_events_organiser_profile.rb:3:in
變化「 NoMethodError:未定義的方法`to_sym」的零:NilClass 你是什麼意思? to_s
在我遷移文件,這是我的代碼 -
def change
change_column :events, :organiser_profile :string
end
def up
change_column :events, :organiser_profile, :string
end
def down
change_column :events, :organiser_profile, :url
end
我也試圖徹底清除列企圖然後用正確的版本,但無濟於事更換。所有即將到來的幫助將不勝感激。
'remove_column:events,:organiser_description' - ** RemoveOrganiserDescriptionFromEvents **應該看起來像這樣。嘗試改變這個 – dp7
爲什麼你有變化,在遷移中上下移動? –
我之前在SO Q&A上看到過它。 –