من یک سری مدل ساختم و این migrate ها رو کد نویس کردم حالا که میخوام دستور
** rake db:migration**
بزنم با ارور زیر مواجه می شوم
bin/rake db:migrate
Running via Spring preloader in process 9020
== 20160311170058 CreateSubjects: migrating ===================================
-- create_table(:subjects)
-- ()
rake aborted!
StandardError: An error has occurred, all later migrations canceled:
undefined local variable or method `'for#<CreateSubjects:0x00000004380ca8>
و این هم کد migration “”
class CreateSubjects < ActiveRecord::Migration
def up
create_table :subjects do |t|
t.string "name"
t.integer "position"
t.boolean "visible" , :default => false
t.timestamps null: false
end
end
def down
drop_table :subjects
this is "sample"
stack overflow let me put this post
end
end
===============================================================
class CreatePages < ActiveRecord::Migration
def up
create_table :pages do |t|
t.integer "subject"
#in ham mishe : t.references :page
t.string "name"
t.string "permalink"
t.integer "position"
t.boolean "visible", :default => false
t.timestamps null: false
end
end
add_index("pages","subject_id")
add_index("pages","permalink")
def down
drop_table :pages
end
end
===================================================================
class CreateSections < ActiveRecord::Migration
def up
create_table :sections do |t|
t.integer "page_id"
#in ham mishe : t.references :page
t.string "name"
t.integer "position"
t.boolean "visible", :default => false
t.string "content_type"
t.string "content"
t.timestamps null: false
end
end
add_index("sections","page_id")
def down
drop_table :sections
end
end
هر جا سرج زدم در مورد لوکال وریبلا بود ولی من اصلا متغیر تعریف نکردم