GithubHelp home page GithubHelp logo

rack-scaffold's Introduction

Rack::Scaffold

Automatically generate RESTful CRUD services

This project is no longer maintained.

Installation

Gemfile

source :rubygems

gem 'rack-scaffold', require: 'rack/scaffold'

gem 'sequel'
gem 'core_data'

gem 'unicorn'
gem 'pg'

Usage

An example web API using a Core Data model can be found the /example directory.

config.ru

require 'sequel'
require 'core_data'
require 'rack/scaffold'

DB = Sequel.connect(ENV['DATABASE_URL'])

run Rack::Scaffold model: './Example.xcdatamodeld', only: [:create, :read]

Available Actions

By default, Rack::Scaffold will enable all of the actions described below. Actions can be whitelisted or blacklisted by passing either the only or except options, respectively.

  • create (POST /resources): Creates a new resource with the fields in a www-form-urlencoded or application/json encoded HTTP request body.
  • read (GET /resources & GET /resources/123): Reads a collection of resources or an individual resource at the specified URI. Supports pagination by passing either page & per_page or limit & offset parameters.
  • update (PUT OR PATCH /resources/123): Updates the specified resource with the fields in a www-form-urlencoded or application/json encoded HTTP request body.
  • delete (DELETE /resources/123): Deletes the specified resource.
  • susbscribe (SUBSCRIBE or GET /resources with Accept: text/event-stream): Subscribes to create, update, and delete actions performed, streaming corresponding JSON Patch diffs. You can read more about the Rocket technique for streaming REST resources at http://rocket.github.io.

Supported Data Models

Contact

Mattt

License

Rack::Scaffold is available under the MIT license. See the LICENSE file for more info.

rack-scaffold's People

Contributors

bartvandendriessche avatar dawogfather avatar dulacp avatar endoze avatar mattt 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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  avatar

rack-scaffold's Issues

example error

When I follow the example steps, in the "bundle" step, terminal return this:

There was a LoadError while evaluating rack-core-data.gemspec: 
cannot load such file -- rack/contrib from
  /*/rack-core-data-master/rack-core-data.gemspec:3:in `<main>'

Does it try to require a relative path? That's been removed in Ruby 1.9.

Using CoreData indexed="YES"

When using an indexed field in CoreData

    <entity name="Song" syncable="YES">
        <attribute name="title" attributeType="String" indexed="YES" syncable="YES"/>
    </entity>

rack-core-data and Sequel throws an exception while trying to create the index in Postgres

PG::Error: ERROR:  syntax error at or near "'title'" (Sequel::DatabaseError)
CREATE INDEX "songs_title_index" ON "songs" ('title')
                                             ^

Sequel is receiving a string for the column name, and single-quoting it when creating an index. Sequel can accept a symbol instead of a string, still create the table, and also create the index.

Quick pull request coming shortly.

Doesn't handle changes to CoreData

I added an additional attribute on a managed object and it was not recognized. It looks like it only creates the table for an entity if it doesn't exist.

I would expect it to either to true up the data model with whatever is in the database or error if there is a difference between the two. Maybe I have unrealistic expectations :)

Heroku deployment

Question, not an issue
What a cool project! I can run it locally without a hitch, on all sorts of data models, but I'm having issues deploying to Heroku.

Here's the directory example:

.env
.git
Example.xcdatamodeld
Gemfile
Gemfile.lock
Procfile
README.md
config.ru

And the heroku push response:

โžœ  example git:(master) gp heroku master
Counting objects: 23, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (21/21), done.
Writing objects: 100% (23/23), 4.49 KiB, done.
Total 23 (delta 7), reused 0 (delta 0)

-----> Heroku receiving push
-----> Ruby/Rack app detected
-----> Installing dependencies using Bundler version 1.2.0
       Running: bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment
       You are trying to install in deployment mode after changing
       your Gemfile. Run `bundle install` elsewhere and add the
       updated Gemfile.lock to version control.
       You have added to the Gemfile:
       * source: source at /tmp
       You have deleted from the Gemfile:
       * source: source at /Users/jp/Documents/sandbox/rack-core-data
       You have changed in the Gemfile:
       * rack-core-data from `source at /tmp` to `no specified source`
 !
 !     Failed to install gems via Bundler.
 !
 !     Heroku push rejected, failed to compile Ruby/rack app

Connection to 10.44.66.18 closed by remote host.
To [email protected]:core-data-test.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:core-data-test.git'

Any thoughts as to what I'm doing wrong?

Thanks,
JP

Heroku Deployment Issue

Question, Not Issue

I've been trying to follow the instructions from the Core Data Buildpack tutorial, and I keep receiving the same error. I was hoping it might make more sense to you than it does to me.

git push heroku master
Counting objects: 33, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (27/27), done.
Writing objects: 100% (33/33), 18.08 KiB, done.
Total 33 (delta 3), reused 0 (delta 0)

-----> Fetching custom git buildpack... done
-----> Core Data app detected
-----> Compiling Core Data model
-----> Setting Locale
       Successfully installed bundler-1.3.5
       Successfully installed sequel-3.48.0
       Building native extensions.  This could take a while...
       Successfully installed pg-0.15.1
       Building native extensions.  This could take a while...
       Building native extensions.  This could take a while...
       Successfully installed rack-1.5.2
       Successfully installed eventmachine-1.0.3
       Successfully installed daemons-1.1.9
       Successfully installed thin-1.5.1
       7 gems installed
       Building native extensions.  This could take a while...
ERROR:  Error installing rack-core-data:
    ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/local/bin/ruby
<internal:lib/rubygems/custom_require>:29:in ``require': no such file to load -- mini_portile (LoadError)
    from <internal:lib/rubygems/custom_require>:29:in ``require'
    from extconf.rb:92:in `<main>'


Gem files will remain installed in /tmp/build_2k8xtnzbinm2f/.gems/gems/nokogiri-1.6.0 for inspection.
Results logged to /tmp/build_2k8xtnzbinm2f/.gems/gems/nokogiri-1.6.0/ext/nokogiri/gem_make.out
-----> Discovering process types
       Procfile declares types     -> (none)
       Default types for Core Data -> web

-----> Compiled slug size: 21.3MB
-----> Launching... done, v7
       http://stormy-sierra-7233.herokuapp.com deployed to Heroku

To [email protected]:stormy-sierra-7233.git
 * [new branch]      master -> master

Any idea what's going wrong?

POST with JSON payload will create empty object

Recreated the Artist/Song model at: http://nameless-mountain-3995.herokuapp.com/artists

When I try to create a new artist with a JSON payload, an empty object is returned. The request should return a 406 if it is unacceptable, otherwise it should create my object with the data provided and return a 201.

Payload:
{"artistDescription":"English rock band formed in Liverpool in 1960","name":"The Beatles"}

Response:

HTTP 201 Created
{
    "artistDescription" : null,
    "name" : null,
    "url" : "/artists/5"
}

PUT to an object will always 406 when sending JSON

Tried this on two separate data models. Recreated the Artists/Song model in the README and pushed to: http://nameless-mountain-3995.herokuapp.com/artists

Actual: If I PUT to /artists/1 with Content-Type application/json, and payload {"artistDescription":"Test"} I will get a 406 Bad Request.

Expected: The API should update my object and return a 200 OK.

This works fine when sending application/x-www-form-urlencoded data.

I've recreated this using both a REST client, and using AFNetworking to hit the server with an AFJSONRequestOperation (with JSON payload).

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.