Links
Acts as Phoneable
Categories
Acts as Phoneable
Allows for phone numbers to be added to multiple and different models.
Resources
Install
* Run the following command: script/plugin install https://svn.nbarthelemy.com/svn/acts_as_phoneable * Create a new rails migration and add the following self.up and self.down methods
class AddPhoneNumberSupport < ActiveRecord::Migration
def self.up
create_table :phone_numbers do |t|
t.column :phoneable_id, :integer, :null => false
t.column :phoneable_type, :string, :limit => 80, :null => false
t.column :number_type, :string, :limit => 25, :null => false
t.column :number, :string, :limit => 25, :null => false
t.column :ext, :string, :limit => 6
end
add_index :phone_numbers, [:phoneable_id, :phoneable_type, :number_type, :number, :ext]
end
def self.down
drop_table :phone_numbers
end
end
Usage
* Make you ActiveRecord model act as phone_numberable. class Model < ActiveRecord::Base acts_as_phoneable end * Add a phone number to a model instance model = Model.new phone_number = Comment.new phone_number.number_type = 'HOME' phone_number.number = '5555555555' phone_number.ext = '1234' model.phone_numbers << phone_number * Each phone_number reference phone_numberable object model = Model.find(1) model.phone_numbers.get(0).phoneable == model
Credits
Xelipe - This plugin is heavily influced by Acts As Tagglable.
Vitals
| Repository | https://svn.nbarthelemy.com/acts_as_phoneable/ |
|---|---|
| License | Rails' (MIT) |
| Tags |
|
| Rating | (3 votes) |
| Created | 16 April 2007 |

