contactable 0.1.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/Manifest +94 -14
- data/README.rdoc +27 -1
- data/Rakefile +1 -1
- data/app/controllers/addresses_controller.rb +3 -0
- data/app/controllers/cities_controller.rb +16 -0
- data/app/controllers/contact_field_actions.rb +60 -0
- data/app/controllers/divisions_controller.rb +17 -0
- data/app/controllers/emails_controller.rb +3 -0
- data/app/controllers/identifications_controller.rb +3 -0
- data/app/controllers/instant_messengers_controller.rb +3 -0
- data/app/controllers/phones_controller.rb +3 -0
- data/app/controllers/websites_controller.rb +3 -0
- data/app/helpers/contactable_helper.rb +46 -0
- data/app/models/address.rb +96 -0
- data/app/models/address_type.rb +5 -0
- data/app/models/city.rb +21 -0
- data/app/models/country.rb +8 -0
- data/app/models/division.rb +26 -0
- data/{generators/contactable/templates → app}/models/email.rb +0 -0
- data/app/models/email_type.rb +5 -0
- data/app/models/identification.rb +7 -0
- data/app/models/identification_type.rb +5 -0
- data/{generators/contactable/templates → app}/models/instant_messenger.rb +0 -0
- data/{generators/contactable/templates → app}/models/instant_messenger_protocol.rb +2 -2
- data/{generators/contactable/templates → app}/models/instant_messenger_type.rb +3 -3
- data/{generators/contactable/templates → app}/models/phone.rb +0 -0
- data/app/models/phone_type.rb +5 -0
- data/{generators/contactable/templates → app}/models/province.rb +0 -0
- data/{generators/contactable/templates → app}/models/website.rb +0 -0
- data/app/models/website_type.rb +5 -0
- data/app/views/addresses/_address.html.erb +31 -0
- data/app/views/cities/index.html.erb +6 -0
- data/app/views/contactable/_contactable.html.erb +11 -0
- data/app/views/contactable/_contactable_field.html.erb +8 -0
- data/app/views/contactable/_fields.html.erb +49 -0
- data/app/views/divisions/index.html.erb +9 -0
- data/app/views/emails/_email.html.erb +2 -0
- data/app/views/identifications/_identification.html.erb +2 -0
- data/app/views/instant_messengers/_instant_messenger.html.erb +3 -0
- data/app/views/phones/_phone.html.erb +2 -0
- data/app/views/websites/_website.html.erb +2 -0
- data/config/contactable_routes.rb +4 -0
- data/contactable.gemspec +5 -5
- data/generators/contactable/USAGE +1 -10
- data/generators/contactable/contactable_generator.rb +35 -32
- data/generators/contactable/lib/insert_commands.rb +33 -0
- data/generators/contactable/templates/README +12 -0
- data/generators/contactable/templates/migrations/create_contactable_related_tables.rb +153 -26
- data/generators/contactable_views/USAGE +1 -0
- data/generators/contactable_views/contactable_views_generator.rb +24 -0
- data/generators/contactable_views/templates/views/formtastic/addresses/_address.html.erb +31 -0
- data/generators/contactable_views/templates/views/formtastic/cities/index.html.erb +6 -0
- data/generators/contactable_views/templates/views/formtastic/contactable/_contactable.html.erb +11 -0
- data/generators/contactable_views/templates/views/formtastic/contactable/_contactable_field.html.erb +8 -0
- data/generators/contactable_views/templates/views/formtastic/contactable/_fields.html.erb +49 -0
- data/generators/contactable_views/templates/views/formtastic/divisions/index.html.erb +9 -0
- data/generators/contactable_views/templates/views/formtastic/emails/_email.html.erb +2 -0
- data/generators/contactable_views/templates/views/formtastic/identifications/_identification.html.erb +2 -0
- data/generators/contactable_views/templates/views/formtastic/instant_messengers/_instant_messenger.html.erb +3 -0
- data/generators/contactable_views/templates/views/formtastic/phones/_phone.html.erb +2 -0
- data/generators/contactable_views/templates/views/formtastic/websites/_website.html.erb +2 -0
- data/generators/contactable_views/templates/views/jintastic/addresses/_address.html.erb +31 -0
- data/generators/contactable_views/templates/views/jintastic/addresses/_form.html.erb +9 -0
- data/generators/contactable_views/templates/views/jintastic/addresses/create.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/addresses/destroy.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/addresses/update.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/cities/index.html.erb +6 -0
- data/generators/contactable_views/templates/views/jintastic/contactable/_birthday.html.erb +1 -0
- data/generators/contactable_views/templates/views/jintastic/contactable/_contactable.html.erb +16 -0
- data/generators/contactable_views/templates/views/jintastic/contactable/_contactable_field.html.erb +14 -0
- data/generators/contactable_views/templates/views/jintastic/contactable/_fields.html.erb +49 -0
- data/generators/contactable_views/templates/views/jintastic/contactable/_name.html.erb +3 -0
- data/generators/contactable_views/templates/views/jintastic/divisions/index.html.erb +9 -0
- data/generators/contactable_views/templates/views/jintastic/emails/_email.html.erb +2 -0
- data/generators/contactable_views/templates/views/jintastic/emails/_form.html.erb +9 -0
- data/generators/contactable_views/templates/views/jintastic/emails/create.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/emails/destroy.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/emails/update.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/identifications/_form.html.erb +9 -0
- data/generators/contactable_views/templates/views/jintastic/identifications/_identification.html.erb +2 -0
- data/generators/contactable_views/templates/views/jintastic/identifications/create.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/identifications/destroy.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/identifications/update.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/instant_messengers/_form.html.erb +9 -0
- data/generators/contactable_views/templates/views/jintastic/instant_messengers/_instant_messenger.html.erb +3 -0
- data/generators/contactable_views/templates/views/jintastic/instant_messengers/create.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/instant_messengers/destroy.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/instant_messengers/update.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/phones/_form.html.erb +9 -0
- data/generators/contactable_views/templates/views/jintastic/phones/_phone.html.erb +2 -0
- data/generators/contactable_views/templates/views/jintastic/phones/create.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/phones/destroy.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/phones/update.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/websites/_form.html.erb +9 -0
- data/generators/contactable_views/templates/views/jintastic/websites/_website.html.erb +2 -0
- data/generators/contactable_views/templates/views/jintastic/websites/create.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/websites/destroy.js.rjs +3 -0
- data/generators/contactable_views/templates/views/jintastic/websites/update.js.rjs +3 -0
- data/lib/contactable.rb +6 -2
- data/lib/contactable/extensions/routes.rb +22 -0
- data/rails/init.rb +1 -0
- metadata +109 -19
- data/generators/contactable/templates/models/address.rb +0 -33
- data/generators/contactable/templates/models/address_type.rb +0 -5
- data/generators/contactable/templates/models/city.rb +0 -4
- data/generators/contactable/templates/models/country.rb +0 -4
- data/generators/contactable/templates/models/email_type.rb +0 -5
- data/generators/contactable/templates/models/phone_type.rb +0 -5
- data/generators/contactable/templates/models/website_type.rb +0 -5
@@ -0,0 +1,9 @@
|
|
1
|
+
<% semantic_remote_form_for [website.owner, website] do |f| %>
|
2
|
+
<% f.inputs do %>
|
3
|
+
<%= render :partial => 'websites/website', :locals => {:f => f} %>
|
4
|
+
<% end %>
|
5
|
+
<% f.buttons do %>
|
6
|
+
<%= f.commit_button %>
|
7
|
+
<li><%= link_to_function t('actions.cancel'), "$('#new_website_form').hide();$('#new_website').reset();$('#new_website_link').show()" %></li>
|
8
|
+
<% end %>
|
9
|
+
<% end %>
|
data/lib/contactable.rb
CHANGED
@@ -62,6 +62,7 @@ module Contactable
|
|
62
62
|
has_many :instant_messengers, :as => :owner
|
63
63
|
has_many :phones, :as => :owner
|
64
64
|
has_many :websites, :as => :owner
|
65
|
+
has_many :identifications, :as => :owner
|
65
66
|
|
66
67
|
accepts_nested_attributes_for :addresses,
|
67
68
|
:reject_if => proc { |attributes| attributes['address'].blank? }, :allow_destroy => true
|
@@ -73,12 +74,15 @@ module Contactable
|
|
73
74
|
:reject_if => proc { |attributes| attributes['number'].blank? }, :allow_destroy => true
|
74
75
|
accepts_nested_attributes_for :websites,
|
75
76
|
:reject_if => proc { |attributes| attributes['address'].blank? }, :allow_destroy => true
|
77
|
+
accepts_nested_attributes_for :identifications,
|
78
|
+
:reject_if => proc { |attributes| attributes['address'].blank? }, :allow_destroy => true
|
76
79
|
EOV
|
77
80
|
end
|
78
|
-
|
79
81
|
end
|
80
82
|
end
|
81
83
|
|
82
84
|
class ActiveRecord::Base
|
83
85
|
include Contactable
|
84
|
-
end
|
86
|
+
end
|
87
|
+
|
88
|
+
require 'contactable/extensions/routes'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
if defined?(ActionController::Routing::RouteSet)
|
2
|
+
class ActionController::Routing::RouteSet
|
3
|
+
def load_routes_with_contactable!
|
4
|
+
lib_path = File.dirname(__FILE__)
|
5
|
+
contactable_routes = File.join(lib_path, *%w[.. .. .. config contactable_routes.rb])
|
6
|
+
unless configuration_files.include?(contactable_routes)
|
7
|
+
add_configuration_file(contactable_routes)
|
8
|
+
end
|
9
|
+
load_routes_without_contactable!
|
10
|
+
end
|
11
|
+
|
12
|
+
alias_method_chain :load_routes!, :contactable
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module ActionController::Resources
|
17
|
+
def contactable_resources(*entities, &block)
|
18
|
+
options = entities.extract_options!
|
19
|
+
resources(:phones, :addresses, :emails, :websites, :instant_messengers, :identifications, options.dup, &block)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
data/rails/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'contactable'
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contactable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 1.0.1
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Luis Perichon
|
@@ -9,7 +14,7 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-03-29 00:00:00 -03:00
|
13
18
|
default_executable:
|
14
19
|
dependencies: []
|
15
20
|
|
@@ -20,32 +25,114 @@ executables: []
|
|
20
25
|
extensions: []
|
21
26
|
|
22
27
|
extra_rdoc_files:
|
28
|
+
- CHANGELOG
|
23
29
|
- LICENSE
|
24
30
|
- README.rdoc
|
25
31
|
- lib/contactable.rb
|
32
|
+
- lib/contactable/extensions/routes.rb
|
26
33
|
files:
|
34
|
+
- CHANGELOG
|
27
35
|
- LICENSE
|
28
36
|
- Manifest
|
29
37
|
- README.rdoc
|
30
38
|
- Rakefile
|
39
|
+
- app/controllers/addresses_controller.rb
|
40
|
+
- app/controllers/cities_controller.rb
|
41
|
+
- app/controllers/contact_field_actions.rb
|
42
|
+
- app/controllers/divisions_controller.rb
|
43
|
+
- app/controllers/emails_controller.rb
|
44
|
+
- app/controllers/identifications_controller.rb
|
45
|
+
- app/controllers/instant_messengers_controller.rb
|
46
|
+
- app/controllers/phones_controller.rb
|
47
|
+
- app/controllers/websites_controller.rb
|
48
|
+
- app/helpers/contactable_helper.rb
|
49
|
+
- app/models/address.rb
|
50
|
+
- app/models/address_type.rb
|
51
|
+
- app/models/city.rb
|
52
|
+
- app/models/country.rb
|
53
|
+
- app/models/division.rb
|
54
|
+
- app/models/email.rb
|
55
|
+
- app/models/email_type.rb
|
56
|
+
- app/models/identification.rb
|
57
|
+
- app/models/identification_type.rb
|
58
|
+
- app/models/instant_messenger.rb
|
59
|
+
- app/models/instant_messenger_protocol.rb
|
60
|
+
- app/models/instant_messenger_type.rb
|
61
|
+
- app/models/phone.rb
|
62
|
+
- app/models/phone_type.rb
|
63
|
+
- app/models/province.rb
|
64
|
+
- app/models/website.rb
|
65
|
+
- app/models/website_type.rb
|
66
|
+
- app/views/addresses/_address.html.erb
|
67
|
+
- app/views/cities/index.html.erb
|
68
|
+
- app/views/contactable/_contactable.html.erb
|
69
|
+
- app/views/contactable/_contactable_field.html.erb
|
70
|
+
- app/views/contactable/_fields.html.erb
|
71
|
+
- app/views/divisions/index.html.erb
|
72
|
+
- app/views/emails/_email.html.erb
|
73
|
+
- app/views/identifications/_identification.html.erb
|
74
|
+
- app/views/instant_messengers/_instant_messenger.html.erb
|
75
|
+
- app/views/phones/_phone.html.erb
|
76
|
+
- app/views/websites/_website.html.erb
|
77
|
+
- config/contactable_routes.rb
|
31
78
|
- generators/contactable/USAGE
|
32
79
|
- generators/contactable/contactable_generator.rb
|
80
|
+
- generators/contactable/lib/insert_commands.rb
|
81
|
+
- generators/contactable/templates/README
|
33
82
|
- generators/contactable/templates/migrations/create_contactable_related_tables.rb
|
34
|
-
- generators/
|
35
|
-
- generators/
|
36
|
-
- generators/
|
37
|
-
- generators/
|
38
|
-
- generators/
|
39
|
-
- generators/
|
40
|
-
- generators/
|
41
|
-
- generators/
|
42
|
-
- generators/
|
43
|
-
- generators/
|
44
|
-
- generators/
|
45
|
-
- generators/
|
46
|
-
- generators/
|
47
|
-
- generators/
|
83
|
+
- generators/contactable_views/USAGE
|
84
|
+
- generators/contactable_views/contactable_views_generator.rb
|
85
|
+
- generators/contactable_views/templates/views/formtastic/addresses/_address.html.erb
|
86
|
+
- generators/contactable_views/templates/views/formtastic/cities/index.html.erb
|
87
|
+
- generators/contactable_views/templates/views/formtastic/contactable/_contactable.html.erb
|
88
|
+
- generators/contactable_views/templates/views/formtastic/contactable/_contactable_field.html.erb
|
89
|
+
- generators/contactable_views/templates/views/formtastic/contactable/_fields.html.erb
|
90
|
+
- generators/contactable_views/templates/views/formtastic/divisions/index.html.erb
|
91
|
+
- generators/contactable_views/templates/views/formtastic/emails/_email.html.erb
|
92
|
+
- generators/contactable_views/templates/views/formtastic/identifications/_identification.html.erb
|
93
|
+
- generators/contactable_views/templates/views/formtastic/instant_messengers/_instant_messenger.html.erb
|
94
|
+
- generators/contactable_views/templates/views/formtastic/phones/_phone.html.erb
|
95
|
+
- generators/contactable_views/templates/views/formtastic/websites/_website.html.erb
|
96
|
+
- generators/contactable_views/templates/views/jintastic/addresses/_address.html.erb
|
97
|
+
- generators/contactable_views/templates/views/jintastic/addresses/_form.html.erb
|
98
|
+
- generators/contactable_views/templates/views/jintastic/addresses/create.js.rjs
|
99
|
+
- generators/contactable_views/templates/views/jintastic/addresses/destroy.js.rjs
|
100
|
+
- generators/contactable_views/templates/views/jintastic/addresses/update.js.rjs
|
101
|
+
- generators/contactable_views/templates/views/jintastic/cities/index.html.erb
|
102
|
+
- generators/contactable_views/templates/views/jintastic/contactable/_birthday.html.erb
|
103
|
+
- generators/contactable_views/templates/views/jintastic/contactable/_contactable.html.erb
|
104
|
+
- generators/contactable_views/templates/views/jintastic/contactable/_contactable_field.html.erb
|
105
|
+
- generators/contactable_views/templates/views/jintastic/contactable/_fields.html.erb
|
106
|
+
- generators/contactable_views/templates/views/jintastic/contactable/_name.html.erb
|
107
|
+
- generators/contactable_views/templates/views/jintastic/divisions/index.html.erb
|
108
|
+
- generators/contactable_views/templates/views/jintastic/emails/_email.html.erb
|
109
|
+
- generators/contactable_views/templates/views/jintastic/emails/_form.html.erb
|
110
|
+
- generators/contactable_views/templates/views/jintastic/emails/create.js.rjs
|
111
|
+
- generators/contactable_views/templates/views/jintastic/emails/destroy.js.rjs
|
112
|
+
- generators/contactable_views/templates/views/jintastic/emails/update.js.rjs
|
113
|
+
- generators/contactable_views/templates/views/jintastic/identifications/_form.html.erb
|
114
|
+
- generators/contactable_views/templates/views/jintastic/identifications/_identification.html.erb
|
115
|
+
- generators/contactable_views/templates/views/jintastic/identifications/create.js.rjs
|
116
|
+
- generators/contactable_views/templates/views/jintastic/identifications/destroy.js.rjs
|
117
|
+
- generators/contactable_views/templates/views/jintastic/identifications/update.js.rjs
|
118
|
+
- generators/contactable_views/templates/views/jintastic/instant_messengers/_form.html.erb
|
119
|
+
- generators/contactable_views/templates/views/jintastic/instant_messengers/_instant_messenger.html.erb
|
120
|
+
- generators/contactable_views/templates/views/jintastic/instant_messengers/create.js.rjs
|
121
|
+
- generators/contactable_views/templates/views/jintastic/instant_messengers/destroy.js.rjs
|
122
|
+
- generators/contactable_views/templates/views/jintastic/instant_messengers/update.js.rjs
|
123
|
+
- generators/contactable_views/templates/views/jintastic/phones/_form.html.erb
|
124
|
+
- generators/contactable_views/templates/views/jintastic/phones/_phone.html.erb
|
125
|
+
- generators/contactable_views/templates/views/jintastic/phones/create.js.rjs
|
126
|
+
- generators/contactable_views/templates/views/jintastic/phones/destroy.js.rjs
|
127
|
+
- generators/contactable_views/templates/views/jintastic/phones/update.js.rjs
|
128
|
+
- generators/contactable_views/templates/views/jintastic/websites/_form.html.erb
|
129
|
+
- generators/contactable_views/templates/views/jintastic/websites/_website.html.erb
|
130
|
+
- generators/contactable_views/templates/views/jintastic/websites/create.js.rjs
|
131
|
+
- generators/contactable_views/templates/views/jintastic/websites/destroy.js.rjs
|
132
|
+
- generators/contactable_views/templates/views/jintastic/websites/update.js.rjs
|
48
133
|
- lib/contactable.rb
|
134
|
+
- lib/contactable/extensions/routes.rb
|
135
|
+
- rails/init.rb
|
49
136
|
- test/contactable_test.rb
|
50
137
|
- contactable.gemspec
|
51
138
|
has_rdoc: true
|
@@ -66,18 +153,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
66
153
|
requirements:
|
67
154
|
- - ">="
|
68
155
|
- !ruby/object:Gem::Version
|
156
|
+
segments:
|
157
|
+
- 0
|
69
158
|
version: "0"
|
70
|
-
version:
|
71
159
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
160
|
requirements:
|
73
161
|
- - ">="
|
74
162
|
- !ruby/object:Gem::Version
|
163
|
+
segments:
|
164
|
+
- 1
|
165
|
+
- 2
|
75
166
|
version: "1.2"
|
76
|
-
version:
|
77
167
|
requirements: []
|
78
168
|
|
79
169
|
rubyforge_project: contactable
|
80
|
-
rubygems_version: 1.3.
|
170
|
+
rubygems_version: 1.3.6
|
81
171
|
signing_key:
|
82
172
|
specification_version: 3
|
83
173
|
summary: Adds contact information to an active record model
|
@@ -1,33 +0,0 @@
|
|
1
|
-
class Address < ActiveRecord::Base
|
2
|
-
|
3
|
-
belongs_to :owner, :polymorphic => true
|
4
|
-
belongs_to :type, :class_name => 'AddressType'
|
5
|
-
belongs_to :city
|
6
|
-
belongs_to :country
|
7
|
-
belongs_to :province
|
8
|
-
|
9
|
-
def city_name
|
10
|
-
city.name if city
|
11
|
-
end
|
12
|
-
|
13
|
-
def city_name=(name)
|
14
|
-
self.city = City.find_or_create_by_name(name.to_s.titleize) unless name.blank?
|
15
|
-
end
|
16
|
-
|
17
|
-
def province_name
|
18
|
-
province.name if province
|
19
|
-
end
|
20
|
-
|
21
|
-
def province_name=(name)
|
22
|
-
self.province = Province.find_or_create_by_name(name.to_s.titleize) unless name.blank?
|
23
|
-
end
|
24
|
-
|
25
|
-
def country_name
|
26
|
-
country.name if country
|
27
|
-
end
|
28
|
-
|
29
|
-
def country_name=(name)
|
30
|
-
self.country = Country.find_or_create_by_name(name.to_s.titleize) unless name.blank?
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|