Giter Club home page Giter Club logo

databasedotcom-rails's Introduction

databasedotcom-rails

Convenience classes to make using the databasedotcom gem with Rails apps even easier

#Installation gem install databasedotcom-rails or, if you use Bundler

gem 'databasedotcom-rails'

Usage

  • Include Databasedotcom::Rails::Controller into your RESTful controller

  • Create a YAML file at RAILS_ROOT/config/databasedotcom.yml file, like so

      ---
      client_id: put-your-client-id-here
      client_secret: put-your-client-secret-here
      username: put-your-username-here
      password: put-your-password-here
      debugging: true
    

    Alternatively, include environment-specific settings: development: client_id: ... test: client_id: ... production: client_id: ...

  • Call YourModel.coerce_params before you pass parameters submitted from an HTML form to your materialized Sobject

Example

class UsersController < ApplicationController
  include Databasedotcom::Rails::Controller
  before_filter :load_user, :except => [:index, :new]

  def index
    @users = User.all
  end

  def show
  end

  def new
    @user = User.new
  end

  def create
    User.create User.coerce_params(params[:user])
    flash[:info] = "The user was created!"
    redirect_to users_path
  end

  def edit
  end

  def update
    @user.update_attributes User.coerce_params(params[:user])
    flash[:info] = "The user was updated!"
    redirect_to user_path(@user)
  end

  def destroy
    @user.delete
    flash[:info] = "The user was deleted!"
    redirect_to users_path
  end

  private

  def load_user
    @user = User.find(params[:id])
  end
end

Note that there is no need to declare the User model anywhere- Databasedotcom::Rails::Controller recognizes it as a known Sobject type from your database.com instance, and materializes it automatically.

License

databasedotcom-rails is released under the MIT License

databasedotcom-rails's People

Contributors

dburkes avatar vfrride avatar andreasschneiderleipzig avatar maroe avatar

Watchers

 avatar

Forkers

maroe

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.