Skip to content
/ further Public

[deprecated] Add more data in your model without adding a column in your table.

License

Notifications You must be signed in to change notification settings

ecleel/further

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

further Gem Version

This gem provides a simple and extremely flexible way to add extra data into your models without adding new column for that.

Installation

Install the latest stable release:

[sudo] gem install further

In Rails, add it to your Gemfile:

gem 'further'

Finally, restart the server to apply the changes.

Note that further is work in Rails 3+ and Ruby 1.9+

Getting Started

Start off by generating an uploader:

rails generate further model

This should give you further_information model and the migrate file.

app/models/further_information.rb
db/migrates/%timestamp%_create_further_information.rb

Then rake db:migrate

rake db:migrate

Open your model file that you want to use further with:

class Site < ActiveRecord::Base
  # you can choose any name
  further :info
end

Open the other model that you want to use further too:

class IP < ActiveRecord::Base
  further :data
end

Now you can add extra data in Site and IP model

s = Site.create info: {alexa_rank: 41253, last_updated: DateTime.now}
s.info[:alexa_rank]  # => 41253
 # you can add more info after you create the object
s.info page_rank: 3
s.info[:page_rank]  # => 3
s.info  # => {:alexa_rank=>41253, :last_updated=>Mon, 25 Nov 2013 18:43:22 +0300, :page_rank=>3}

IP.first.data # => {}
IP.first.data last_check: DateTime.now
# => {:last_check=>Mon, 25 Nov 2013 18:44:13 +0300 }

About

[deprecated] Add more data in your model without adding a column in your table.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published