active_record_schema 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +12 -12
- data/VERSION +1 -1
- data/active_record_schema.gemspec +2 -2
- data/lib/active_record_schema/dsl.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -114,7 +114,7 @@ Lets try to add a HBTM association to our `Post` model
|
|
114
114
|
_ex._
|
115
115
|
|
116
116
|
``` rb
|
117
|
-
#
|
117
|
+
# post.rb
|
118
118
|
class Post < ActiveRecord::Base
|
119
119
|
field :title
|
120
120
|
field :body, :as => :text
|
@@ -133,16 +133,16 @@ Now running
|
|
133
133
|
will generate:
|
134
134
|
|
135
135
|
``` rb
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
end
|
142
|
-
add_index :contents_users, "content_id"
|
143
|
-
add_index :contents_users, "user_id"
|
144
|
-
end
|
136
|
+
class AddVotersToPosts < ActiveRecord::Migration
|
137
|
+
def change
|
138
|
+
create_table :posts_users, :id => false do |t|
|
139
|
+
t.integer "post_id"
|
140
|
+
t.integer "user_id"
|
145
141
|
end
|
142
|
+
add_index :posts_users, "post_id"
|
143
|
+
add_index :posts_users, "user_id"
|
144
|
+
end
|
145
|
+
end
|
146
146
|
```
|
147
147
|
|
148
148
|
## Single Table Inheritance (STI)
|
@@ -275,11 +275,11 @@ end
|
|
275
275
|
|
276
276
|
* ### `belongs_to(name, options = {})`
|
277
277
|
|
278
|
-
Adds a new foreign key column for the association to the schema and then delegates to `ActiveRecord::Base.belongs_to`. If the association is
|
278
|
+
Adds a new foreign key column for the association to the schema and then delegates to `ActiveRecord::Base.belongs_to`. If the association is polymorphic a column for foreign type is also generated.
|
279
279
|
|
280
280
|
#### options
|
281
281
|
|
282
|
-
* **:index** : Specify wether or not the foreing key column should be indexed, default to `true`. If the association is
|
282
|
+
* **:index** : Specify wether or not the foreing key column should be indexed, default to `true`. If the association is polymorphic creates an index on both foreign key and foreing type
|
283
283
|
|
284
284
|
|
285
285
|
* ### `has_and_belongs_to_many(name, options = {}, &extension)`
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.4
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "active_record_schema"
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["mcasimir"]
|
12
|
-
s.date = "2012-05-
|
12
|
+
s.date = "2012-05-08"
|
13
13
|
s.description = "ActiveRecordSchema is an ActiveRecord extension that allows you to write the database schema for a model within the model itself and to generate migrations directly from models."
|
14
14
|
s.email = "maurizio.cas@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -35,7 +35,7 @@ module ActiveRecordSchema
|
|
35
35
|
foreign_key = options[:foreign_key] || "#{name}_id"
|
36
36
|
field :"#{foreign_key}"
|
37
37
|
|
38
|
-
if options[:
|
38
|
+
if options[:polymorphic]
|
39
39
|
foreign_type = options[:foreign_type] || "#{name}_type"
|
40
40
|
field :"#{foreign_type}"
|
41
41
|
add_index [:"#{foreign_key}", :"#{foreign_type}"] if !skip_index
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -89,7 +89,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
89
|
version: '0'
|
90
90
|
segments:
|
91
91
|
- 0
|
92
|
-
hash:
|
92
|
+
hash: 2848044232575768801
|
93
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|