Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method `create_schema' for Nuts::Models:Module (NoMethodError) #1

Open
tablecell opened this issue Aug 28, 2021 · 0 comments

Comments

@tablecell
Copy link

tablecell commented Aug 28, 2021

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
 


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant