camping
camping copied to clipboard
undefined method `create_schema' for Nuts::Models:Module (NoMethodError)
test.rb
require "camping"
require "active_record"
Base = ActiveRecord::Base
module Nuts
module Models
class Post < Base
belongs_to :user
end
class Comment < Base; belongs_to :user; end
class User < Base; end
#class BasicFields < V 1.1
class BasicFields < ActiveRecord::Migration[4.2]
def self.up
create_table :blog_posts, :force => true do |t|
t.integer :user_id, :null => false
t.string :title, :limit => 255
t.text :body, :html_body
t.timestamps
end
create_table :blog_users, :force => true do |t|
t.string :username, :password
end
create_table :blog_comments, :force => true do |t|
t.integer :post_id, :null => false
t.string :username
t.text :body, :html_body
t.timestamps
end
User.create :username => "admin", :password => "camping"
end
def self.down
drop_table :blog_posts
drop_table :blog_users
drop_table :blog_comments
end
end
end
end
def Nuts.create
Nuts::Models.create_schema
end
Camping::Models::Base.establish_connection :adapter => "sqlite3", :database => "example.db"
Nuts.create