public
Description: ActiveRecord plugin to save IPs as ints, but get and set them as dotted decimal strings
Homepage:
Clone URL: git://github.com/apeckham/has_ip_column.git
name age message
file MIT-LICENSE Tue Nov 11 15:47:12 -0800 2008 ap - first commit [apeckham]
file README Sun Dec 28 00:13:37 -0800 2008 ap - clarifying readme [apeckham]
file Rakefile Loading commit data...
directory generators/ Sat Dec 27 23:51:13 -0800 2008 ap - fixed migration name in generator [apeckham]
file init.rb
directory lib/
directory test/
README
This code helps you store IP addresses as ints in the database.

Create a column on your ActiveRecord model to store IP addresses.

  script/generate add_ip_column MyModel
  rake db:migrate

Then in your model, use has_ip_column...

  class MyModel < ActiveRecord::Base    
    has_ip_column :ipaddress
    ...
  end

On instances of MyModel, you can now set ipaddress as a dotted decimal string:

  MyModel.new(:ipaddress => "201.102.201.102")

When you save the model, it's stored as an integer in the database.