Giter Site home page Giter Site logo

rom-rails's Introduction

Gem Version Build Status Dependency Status Code Climate Test Coverage Inline docs

rom-rails

Rails integration for Ruby Object Mapper.

Installation and setup

In your Gemfile:

gem 'rom'
gem 'rom-rails'

Schema

Defining schema is only required for adapters that don't support inferring schema automatically. This means if you're using rom-sql you don't have to define the schema. In other cases the railtie expects the schema to be in db/rom/schema.rb which is loaded before relations and mappers.

Relations and mappers

The railtie automatically loads relations and mappers from app/relations and app/mappers and finalizes the environment afterwards. During the booting process rom's setup object is available via Rails.application.config.rom.setup.

Relations in controllers

The recommended way of using relations in controllers is to specify which relations are needed for particular actions using a DSL provided by the railtie:

class UsersController < ApplicationController
  relation 'users.index', only: :index
  relation 'users.by_name', only: :search, requires: :name

  def index
    render
  end

  def search
    render :index
  end
end

By doing this actions will have access to users which is also set as a helper method making it available in the views.

This means no database interaction will take place in the views or helpers as ROM materializes relations when "injecting" them into controller actions.

Status

This project is still in beta state. For examples of usage please take a look at spec/dummy app.

Proper documentation will be added once the interface is stable.

Roadmap

Please refer to issues.

Community

License

See LICENSE file.

rom-rails's People

Contributors

solnic avatar

Watchers

Piotr Szotkowski avatar James Cloos avatar

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.