Giter Club home page Giter Club logo

grape-activerecord's Introduction

grape-activerecord's People

Contributors

goddamnyouryan avatar jhollinger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

grape-activerecord's Issues

requiring "grape/activerecord/rake" throws error

When I require the "grape/activerecord/rake" file the app wont start anymore. This is the error:

.../gems/activerecord-4.2.3/lib/active_record/railties/databases.rake:3:in `<top (required)>': undefined method `namespace' for main:Object (NoMethodError)

Rake tasks do actually work, so could use them by just only enabling the lines when I need migration tasks, but its nicer if I can always have the tasks available.

Can't load app in db:environment if a config/database.yml file exists

Our project uses ENVied to refer to database host, username, etc. in the config/database.yml file, so we need to have loaded ENVied before loading active_record and connecting to the database. This project's README suggests putting such application loading in a rake task db:environment. This would load fine if our database config was located somewhere else, but since it's in config/database.yml your defaults.rb file calls database_file= before this environment task is executed, which fails because ENVied hasn't loaded yet.

It would be preferable if grape-activerecord didn't set the database file until the end of the database environment task, so that if any setup is required in order for activerecord to use the database file it can be performed there.

Ignoring pool size config

ActiveRecord config loader:

Grape::ActiveRecord.database_file = File.join(__dir__, '..', 'config', 'database.yml')

database.yml:

development:
  adapter: postgresql
  host: 192.168.7.16
  encoding: unicode
  username: postgres
  password: secret
  database: app_development
  pool: 10

# 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:
  adapter: postgresql
  host: 192.168.7.16
  encoding: unicode
  username: postgres
  password: secret
  database: app_test
  pool: 10

production:
  adapter: postgresql
  host: 192.168.7.16
  encoding: unicode
  username: postgres
  password: secret
  database: app_production
  pool: 10

Then when I test it with:

ab -c 10 -n 1000 http://192.168.7.10/users

It opens exactly 20 connections to PostgreSQL:

tcp        0    139 192.168.7.16:postgresql 192.168.7.10:39666    ESTABLISHED
tcp        0      0 192.168.7.16:postgresql 192.168.7.10:39658    ESTABLISHED
tcp        0      0 192.168.7.16:postgresql 192.168.7.10:39664    ESTABLISHED
tcp        0      0 192.168.7.16:postgresql 192.168.7.10:39662    ESTABLISHED
...

The same if I make pool: 2 or pool: 70.

include Grape::ActiveRecord::Extension throws error

Hi, Thanks for writing this gem. I've come across this issue:

Using grape-activerecord 0.0.8
Using activerecord 4.2.3

When I follow the README and include Grape::ActiveRecord::Extension in my Grape API class I get the following error:

undefined method 'downcase' for 2:Fixnum

Ruby    /home/vagrant/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/utils.rb: in [], line 501

Looking into that code there are just these two lines:

Grape::ActiveRecord.setup!
app.use ::ActiveRecord::ConnectionAdapters::ConnectionManagement

When I remove the include Grape::ActiveRecord::Extension from the API class and replace it with just Grape::ActiveRecord.setup! it works fine.

Following your README I have put in config.ru use ActiveRecord::ConnectionAdapters::ConnectionManagement

I played around with removing the use from config.ru since it seems redundant when including the mixin, but that didn't remove the error. any idea?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.