Sha256: 374afd6133eb89166eaa23e20357171b20a846c5611c0dfe474df874de094135

Contents?: true

Size: 950 Bytes

Versions: 10

Compression:

Stored size: 950 Bytes

Contents

# ActiveRecord Configuration
# We are not using :memory: database to handle javascript requests on controller
require 'active_record/railtie'
ActiveRecord::Base.configurations = {'test' => {:adapter => 'sqlite3', :database => 'paloma_test'}}
ActiveRecord::Base.establish_connection('test')


# Models
class Article < ActiveRecord::Base
  attr_accessible :title, :body, :category, :category_id
  belongs_to :category
  validates_presence_of :title
end


class Category < ActiveRecord::Base
  attr_accessible :name
  has_many :articles, :dependent => :destroy
  validates_presence_of :name
end


# Migration
class CreateTables < ActiveRecord::Migration
  def self.up
    create_table :articles, :force => true do |t| 
      t.string :title
      t.string :body
      t.references :category
    end
    
    create_table :categories, :force => true do |t|
      t.string :name
    end
  end
end


ActiveRecord::Migration.verbose = false
CreateTables.up

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
paloma-1.2.6 spec/sample_app/models.rb
paloma-1.2.5 spec/sample_app/models.rb
paloma-1.2.4 spec/sample_app/models.rb
paloma-1.2.3 spec/sample_app/models.rb
paloma-1.2.2 spec/sample_app/models.rb
paloma-1.2.1 spec/sample_app/models.rb
paloma-1.2.0 spec/sample_app/models.rb
paloma-0.0.8 spec/sample_app/models.rb
paloma-0.0.7 spec/sample_app/models.rb
paloma-0.0.6 spec/sample_app/models.rb