attr_accessible_block 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +6 -6
- data/Rakefile +1 -1
- data/attr_accessible_block.gemspec +3 -3
- data/lib/attr_accessible_block.rb +4 -0
- data/test/schema.rb +3 -3
- metadata +5 -5
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
AttrAccessibleBlock 0.2.
|
|
1
|
+
AttrAccessibleBlock 0.2.2
|
|
2
2
|
=========================
|
|
3
3
|
|
|
4
4
|
This is an ActiveRecord plugin with possibility to define block inside the `attr_accessible` class method.
|
|
@@ -49,8 +49,8 @@ Now it's possible to do it easier:
|
|
|
49
49
|
|
|
50
50
|
class User < ActiveRecord::Base
|
|
51
51
|
attr_accessible do
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
add [:password, :password_confirmation]
|
|
53
|
+
add :email if record.new_record?
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
|
|
@@ -74,9 +74,9 @@ Easy, with `sentient_user` gem and add the code to the `config/initializers/plug
|
|
|
74
74
|
Now `user` method available, you can check:
|
|
75
75
|
|
|
76
76
|
attr_accessible do
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
add [:password, :password_confirmation]
|
|
78
|
+
add :email if record.new_record? || user.manager?
|
|
79
|
+
add [:some_secret_fields, :another] if user.manager?
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
What if I want to provide an total accessibility for the admin user?
|
data/Rakefile
CHANGED
|
@@ -18,7 +18,7 @@ Jeweler::Tasks.new do |gem|
|
|
|
18
18
|
gem.description = %Q{Convinient possibility to change attr_accessible on the fly, using definition of the required accessible attributes in a block.}
|
|
19
19
|
gem.email = "dmitry.polushkin@gmail.com"
|
|
20
20
|
gem.authors = ["Dmitry Polushkin"]
|
|
21
|
-
gem.version = '0.2.
|
|
21
|
+
gem.version = '0.2.2'
|
|
22
22
|
gem.add_runtime_dependency 'activerecord', '>= 2.3.5'
|
|
23
23
|
end
|
|
24
24
|
Jeweler::RubygemsDotOrgTasks.new
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{attr_accessible_block}
|
|
8
|
-
s.version = "0.2.
|
|
8
|
+
s.version = "0.2.2"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Dmitry Polushkin"]
|
|
12
|
-
s.date = %q{2011-
|
|
12
|
+
s.date = %q{2011-06-01}
|
|
13
13
|
s.description = %q{Convinient possibility to change attr_accessible on the fly, using definition of the required accessible attributes in a block.}
|
|
14
14
|
s.email = %q{dmitry.polushkin@gmail.com}
|
|
15
15
|
s.extra_rdoc_files = [
|
|
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
|
|
|
34
34
|
s.homepage = %q{http://github.com/dmitry/attr_accessible_block}
|
|
35
35
|
s.licenses = ["MIT"]
|
|
36
36
|
s.require_paths = ["lib"]
|
|
37
|
-
s.rubygems_version = %q{1.
|
|
37
|
+
s.rubygems_version = %q{1.6.2}
|
|
38
38
|
s.summary = %q{Attribute accessible block (attr_accessible with a dynamic block possibility)}
|
|
39
39
|
s.test_files = [
|
|
40
40
|
"test/schema.rb",
|
data/test/schema.rb
CHANGED
|
@@ -19,8 +19,8 @@ end
|
|
|
19
19
|
|
|
20
20
|
class User < ActiveRecord::Base
|
|
21
21
|
attr_accessible do
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
add [:password, :profile_attributes]
|
|
23
|
+
add :email if record.new_record? || 'manager' == user.role
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
has_one :profile
|
|
@@ -43,7 +43,7 @@ end
|
|
|
43
43
|
|
|
44
44
|
class Profile < ActiveRecord::Base
|
|
45
45
|
attr_accessible do
|
|
46
|
-
|
|
46
|
+
add [:first_name, :last_name] if record.new_record?
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
belongs_to :user
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: attr_accessible_block
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 19
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 2
|
|
9
|
-
-
|
|
10
|
-
version: 0.2.
|
|
9
|
+
- 2
|
|
10
|
+
version: 0.2.2
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Dmitry Polushkin
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2011-
|
|
18
|
+
date: 2011-06-01 00:00:00 +01:00
|
|
19
19
|
default_executable:
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|
|
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
179
179
|
requirements: []
|
|
180
180
|
|
|
181
181
|
rubyforge_project:
|
|
182
|
-
rubygems_version: 1.
|
|
182
|
+
rubygems_version: 1.6.2
|
|
183
183
|
signing_key:
|
|
184
184
|
specification_version: 3
|
|
185
185
|
summary: Attribute accessible block (attr_accessible with a dynamic block possibility)
|