Project

obviously

0.0
No commit activity in last 3 years
No release in over 3 years
Makes using namespaced model names, like Project::Discussion, much less painful. No more `class_name: 'Project::Discussion'` options required.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 2.0.0

Runtime

 Project Readme

Donate to charity: water via Gittip

obviously

Guess obvious association class names in ActiveRecord.

Makes using namespaced model names, like Project::Discussion, much less painful.

Installation

Add this to your Gemfile:

gem 'obviously'

Usage

Notice the lack of class_name: 'User::Membership' style options in the associations. Works with belongs_to, has_one and has_many:

class User < ActiveRecord::Base
    class Membership < ActiveRecord::Base
      connection.create_table :user_memberships do |t|
        t.references :user
        t.references :project
      end unless table_exists?

      belongs_to :user
      belongs_to :project
    end

    connection.create_table :users do |t|
      t.string :email
    end unless table_exists?

    has_many :memberships

    has_many :users,
      through: :memberships
  end

  class Project < ActiveRecord::Base
    connection.create_table :projects do |t|
      t.string :name
    end unless table_exists?

    has_many :memberships

    has_many :users,
      through: :memberships
  end