Created
December 18, 2020 03:53
-
-
Save glaszig/5cfd26ea500b5742e8e55d40005141d2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require "bundler/inline" | |
gemfile(true) do | |
source "https://rubygems.org" | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
gem "activerecord", "6.1.0" | |
gem "sqlite3" | |
gem "awesome_nested_set", require: false | |
end | |
require "active_record" | |
require "awesome_nested_set" | |
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Schema.define do | |
create_table :categories do |t| | |
t.string :name | |
t.integer :parent_id, null: true, index: true | |
t.integer :lft, null: false, index: true | |
t.integer :rgt, null: false, index: true | |
end | |
end | |
class Category < ActiveRecord::Base | |
acts_as_nested_set | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment