Sha256: d0929350933bdab8b1b89ffcdd3bf0ceee914fbecef4d68819c2625516747d19

Contents?: true

Size: 986 Bytes

Versions: 2

Compression:

Stored size: 986 Bytes

Contents

require 'rubygems'
require 'sinatra'
require 'classy_resources/active_record'
require 'activerecord'

ActiveRecord::Base.configurations = {'sqlite3' => {:adapter  => 'sqlite3', 
                                                   :database => ':memory:'}}
ActiveRecord::Base.establish_connection('sqlite3')

ActiveRecord::Base.logger = Logger.new(STDERR)
ActiveRecord::Base.logger.level = Logger::WARN

ActiveRecord::Schema.define(:version => 0) do
  create_table :posts do |t|
    t.string :title
  end

  create_table :comments do |t|
    t.integer :post_id
    t.string :author
  end
end

class Post < ActiveRecord::Base
  has_many :comments
end

class Comment < ActiveRecord::Base
  belongs_to :post
end


define_resource :posts, :collection => [:get, :post],
                        :member     => [:get, :put, :delete],
                        :formats    => [:xml, :json]

define_resource :comments, :collection => [:get, :post],
                           :parent     => :posts

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
giraffesoft-classy_resources-0.1.0 test/fixtures/active_record_test_app.rb
giraffesoft-classy_resources-0.1.1 test/fixtures/active_record_test_app.rb