safe_attributes 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -2
- data/README.rdoc +22 -16
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/safe_attributes.gemspec +4 -4
- data/spec/spec_helper.rb +3 -3
- metadata +6 -6
data/Gemfile
CHANGED
data/README.rdoc
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
= SafeAttributes
|
2
2
|
|
3
|
-
By default Rails creates attribute accessors for all
|
4
|
-
in each model. Columns with specific names
|
5
|
-
|
6
|
-
|
7
|
-
named 'class', though there
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
By default Rails/ActiveRecord 3 creates attribute accessors for all
|
4
|
+
database table columns in each model. Columns with specific names
|
5
|
+
cause errors because they result in ActiveRecord redefining a key
|
6
|
+
method within either Ruby or ActiveRecord in an incompatible way. A
|
7
|
+
classic example is any table with a column named 'class', though there
|
8
|
+
are other possible examples. Put simply, this gem makes it easier
|
9
|
+
to support a legacy database schema with ActiveRecord.
|
10
|
+
|
11
|
+
Using this gem enhances ActiveRecord to change the default behavior for
|
12
|
+
the creation of attribute accessors. Instance methods in
|
13
|
+
ActiveRecord::Base, except for 'id', are combined into a list. This list
|
12
14
|
is checked before the creation of two types of attribute accessors:
|
13
15
|
attribute() and attribute=().
|
14
16
|
|
@@ -31,20 +33,24 @@ you can use a couple of different approaches.
|
|
31
33
|
* model_instance.read_attribute('attribute')
|
32
34
|
* model_instance.write_attribute('attribute', value)
|
33
35
|
|
36
|
+
You can read more about reserved words[http://oldwiki.rubyonrails.org/rails/pages/ReservedWords] and magic field names[http://oldwiki.rubyonrails.org/rails/pages/MagicFieldNames] on Rails' wiki pages.
|
37
|
+
|
34
38
|
== Installing
|
35
39
|
|
36
|
-
gem install safe_attributes
|
40
|
+
gem install safe_attributes
|
37
41
|
|
38
|
-
|
39
|
-
|
40
|
-
activemodel (3.0.3 at this time) and arel. These are not necessary
|
41
|
-
for the gem and this should not be happening. As long as you have
|
42
|
-
activerecord 3.0.0 or better it should work. Here's the error message
|
43
|
-
in case you see it.
|
42
|
+
If you do not have the newest version of ActiveRecord, rubygems will
|
43
|
+
attempt to install it for you. This can result in an error like below.
|
44
44
|
|
45
45
|
ERROR: Error installing safe_attributes:
|
46
46
|
activemodel requires activesupport (= 3.0.3, runtime)
|
47
47
|
|
48
|
+
You can use this gem with activerecord and activesupport >= 3.0 and < 3.1.
|
49
|
+
If you already have an appropriate version of activerecord and
|
50
|
+
activesupport installed then use --ignore-dependencies to avoid this
|
51
|
+
error. If you have the latest version already then the gem should install
|
52
|
+
without issue using the recommended approach above.
|
53
|
+
|
48
54
|
== Using
|
49
55
|
|
50
56
|
=== Rails
|
data/Rakefile
CHANGED
@@ -17,8 +17,8 @@ Jeweler::Tasks.new do |gem|
|
|
17
17
|
gem.version = version
|
18
18
|
gem.homepage = "http://github.com/bjones/safe_attributes"
|
19
19
|
gem.license = "MIT"
|
20
|
-
gem.summary = %Q{
|
21
|
-
gem.description = %Q{
|
20
|
+
gem.summary = %Q{Useful for legacy database support, adds support for reserved word column names with ActiveRecord}
|
21
|
+
gem.description = %Q{Better support for legacy database schemas for ActiveRecord, such as columns named class, or any other name that conflicts with an instance method of ActiveRecord.}
|
22
22
|
gem.email = "cbj@gnu.org"
|
23
23
|
gem.authors = ["Brian Jones"]
|
24
24
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
data/safe_attributes.gemspec
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{safe_attributes}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Brian Jones"]
|
12
|
-
s.date = %q{
|
13
|
-
s.description = %q{
|
12
|
+
s.date = %q{2011-01-24}
|
13
|
+
s.description = %q{Better support for legacy database schemas for ActiveRecord, such as columns named class, or any other name that conflicts with an instance method of ActiveRecord.}
|
14
14
|
s.email = %q{cbj@gnu.org}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
s.licenses = ["MIT"]
|
35
35
|
s.require_paths = ["lib"]
|
36
36
|
s.rubygems_version = %q{1.3.7}
|
37
|
-
s.summary = %q{
|
37
|
+
s.summary = %q{Useful for legacy database support, adds support for reserved word column names with ActiveRecord}
|
38
38
|
s.test_files = [
|
39
39
|
"spec/safe_attributes/safe_attributes_spec.rb",
|
40
40
|
"spec/spec_helper.rb"
|
data/spec/spec_helper.rb
CHANGED
@@ -2,11 +2,11 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
2
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
|
-
|
5
|
+
require 'bundler'
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
|
6
8
|
require 'active_record'
|
7
|
-
gem 'activesupport', '>= 3.0.0'
|
8
9
|
require 'active_support'
|
9
|
-
|
10
10
|
require 'safe_attributes'
|
11
11
|
require 'rspec'
|
12
12
|
require 'rspec/autorun'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: safe_attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 2
|
10
|
+
version: 1.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Brian Jones
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-01-24 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -126,7 +126,7 @@ dependencies:
|
|
126
126
|
- 0
|
127
127
|
version: "0"
|
128
128
|
requirement: *id007
|
129
|
-
description:
|
129
|
+
description: Better support for legacy database schemas for ActiveRecord, such as columns named class, or any other name that conflicts with an instance method of ActiveRecord.
|
130
130
|
email: cbj@gnu.org
|
131
131
|
executables: []
|
132
132
|
|
@@ -181,7 +181,7 @@ rubyforge_project:
|
|
181
181
|
rubygems_version: 1.3.7
|
182
182
|
signing_key:
|
183
183
|
specification_version: 3
|
184
|
-
summary:
|
184
|
+
summary: Useful for legacy database support, adds support for reserved word column names with ActiveRecord
|
185
185
|
test_files:
|
186
186
|
- spec/safe_attributes/safe_attributes_spec.rb
|
187
187
|
- spec/spec_helper.rb
|