Permalink
Browse files

Added ActiveRecord with the grape-active-record gem

  • Loading branch information...
tonymadbrain committed Nov 24, 2015
1 parent 8b9ec95 commit 412226fc308256069c7fb3c490b9ed476753c199
Showing with 81 additions and 1 deletion.
  1. +3 −0 .gitignore
  2. +6 −0 Gemfile
  3. +19 −0 Gemfile.lock
  4. +9 −0 Rakefile
  5. +1 −1 app/api/notes.rb
  6. +1 −0 app/core.rb
  7. +2 −0 config.ru
  8. +40 −0 config/database-sample.yml
View
@@ -20,3 +20,6 @@
#ruby version and gem
.ruby-*
#configs
config/database.yml
View
@@ -3,7 +3,13 @@ source 'https://rubygems.org'
ruby '2.2.3'
gem 'rack-fiber_pool', :require => 'rack/fiber_pool'
gem 'grape'
gem 'grape-swagger'
gem 'grape-activerecord'
gem 'rake'
gem 'mysql2'
gem 'pry'
gem 'awesome_print'
View
@@ -1,12 +1,20 @@
GEM
remote: https://rubygems.org/
specs:
activemodel (4.2.5)
activesupport (= 4.2.5)
builder (~> 3.1)
activerecord (4.2.5)
activemodel (= 4.2.5)
activesupport (= 4.2.5)
arel (~> 6.0)
activesupport (4.2.5)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.3)
awesome_print (1.6.1)
axiom-types (0.1.1)
descendants_tracker (~> 0.0.4)
@@ -29,20 +37,27 @@ GEM
rack-accept
rack-mount
virtus (>= 1.0.0)
grape-activerecord (1.1.2)
activerecord (~> 4.0)
grape (~> 0.1)
hashie-forbidden_attributes (~> 0.1.1)
grape-entity (0.4.8)
activesupport
multi_json (>= 1.3.2)
grape-swagger (0.10.2)
grape (>= 0.8.0)
grape-entity
hashie (3.4.3)
hashie-forbidden_attributes (0.1.1)
hashie (>= 3.0)
i18n (0.7.0)
ice_nine (0.11.1)
json (1.8.3)
method_source (0.8.2)
minitest (5.8.3)
multi_json (1.11.2)
multi_xml (0.5.5)
mysql2 (0.4.1)
pry (0.10.3)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
@@ -53,6 +68,7 @@ GEM
rack-fiber_pool (0.9.3)
rack-mount (0.8.3)
rack (>= 1.0.0)
rake (10.4.2)
slop (3.6.0)
thread_safe (0.3.5)
tzinfo (1.2.2)
@@ -69,9 +85,12 @@ PLATFORMS
DEPENDENCIES
awesome_print
grape
grape-activerecord
grape-swagger
mysql2
pry
rack-fiber_pool
rake
BUNDLED WITH
1.10.6
View
@@ -0,0 +1,9 @@
require "bundler/setup"
require "grape/activerecord/rake"
namespace :db do
# Some db tasks require your app code to be loaded, or at least your gems
task :environment do
require_relative "app/core"
end
end
View
@@ -1,7 +1,7 @@
class Notes < Grape::API
version 'v1', using: :header, vendor: 'tonymadbrain'
format :json
format :json
resource 'notes' do
View
@@ -1,3 +1,4 @@
RACK_ENV = (ENV['RACK_ENV'] || 'development').to_sym
require 'rubygems'
require 'bundler'
Bundler.require
View
@@ -5,6 +5,8 @@ require 'grape'
require './app/core'
require './app/api/notes'
use ActiveRecord::ConnectionAdapters::ConnectionManagement
run Notes
use Rack::Static,
View
@@ -0,0 +1,40 @@
# MySQL. Versions 5.0+ are recommended.
#
# Install the MYSQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
#
default: &default
adapter: mysql2
encoding: utf8
pool: 5
username: root
password:
host: 127.0.0.1
port: 3306
socket: /tmp/mysql.sock
development:
<<: *default
database: grape_rack_swagger_development
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: grape_rack_swagger_test
# Avoid production credentials in the repository,
# instead read the configuration from the environment.
#
# Example:
# mysql2://myuser:mypass@localhost/somedatabase
#
production:
url: <%= ENV["DATABASE_URL"] %>

0 comments on commit 412226f

Please sign in to comment.