jtable-rails 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 +12 -1
- data/VERSION +1 -1
- data/jtable-rails.gemspec +3 -1
- data/spec/model_specs/custom_attributes_spec.rb +23 -0
- data/spec/support/rails_app/app/models/person.rb +6 -0
- metadata +5 -3
data/README.md
CHANGED
@@ -27,4 +27,15 @@ One-to-One Association
|
|
27
27
|
jtable :one_to_one, :first_name, :last_name, {:place => [:city, :state]}
|
28
28
|
end
|
29
29
|
|
30
|
-
This creates a jTable called *one_to_one* with the *person* attributes *first_name* and *last_name*, and the *place_attributes* *city* and *state
|
30
|
+
This creates a jTable called *one_to_one* with the *person* attributes *first_name* and *last_name*, and the *place_attributes* *city* and *state*.
|
31
|
+
|
32
|
+
Custom Attributes
|
33
|
+
-----------------
|
34
|
+
class Person < ActiveRecord::Base
|
35
|
+
jtable :custom, :first_name, :last_name, :date_of_birth
|
36
|
+
|
37
|
+
def jtable_custom_attribute_date_of_birth
|
38
|
+
self.date_of_birth.strftime("%m/%d/%Y")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
This will make the *date_of_birth* field be displayed with the format *mm/dd/yyyy*.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/jtable-rails.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{jtable-rails}
|
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 = ["Taylor Yelverton"]
|
@@ -37,6 +37,7 @@ Gem::Specification.new do |s|
|
|
37
37
|
"spec/fabricators/person.rb",
|
38
38
|
"spec/fabricators/place.rb",
|
39
39
|
"spec/model_specs/basic_spec.rb",
|
40
|
+
"spec/model_specs/custom_attributes_spec.rb",
|
40
41
|
"spec/model_specs/one_to_one_spec.rb",
|
41
42
|
"spec/spec_helper.rb",
|
42
43
|
"spec/support/rails_app/.DS_Store",
|
@@ -105,6 +106,7 @@ Gem::Specification.new do |s|
|
|
105
106
|
"spec/fabricators/person.rb",
|
106
107
|
"spec/fabricators/place.rb",
|
107
108
|
"spec/model_specs/basic_spec.rb",
|
109
|
+
"spec/model_specs/custom_attributes_spec.rb",
|
108
110
|
"spec/model_specs/one_to_one_spec.rb",
|
109
111
|
"spec/spec_helper.rb",
|
110
112
|
"spec/support/rails_app/app/controllers/application_controller.rb",
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe "Custom Attributes" do
|
4
|
+
before(:each) do
|
5
|
+
@person = Fabricate(:person, :place => Fabricate(:place))
|
6
|
+
|
7
|
+
@params = {
|
8
|
+
:searchable_columns => ["first_name", "last_name", "age", "date_of_birth", "gender"],
|
9
|
+
:column_search => {},
|
10
|
+
:limit => "5",
|
11
|
+
:offset => "0",
|
12
|
+
:search => "",
|
13
|
+
:sort_column => "",
|
14
|
+
:sort_direction => ""
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should return the correctly formatted attributes" do
|
19
|
+
date = 10.years.ago
|
20
|
+
@person.date_of_birth = date
|
21
|
+
@person.jtable_custom_attributes_attribute_date_of_birth.should eql(date.strftime("%m/%d/%Y"))
|
22
|
+
end
|
23
|
+
end
|
@@ -4,4 +4,10 @@ class Person < ActiveRecord::Base
|
|
4
4
|
jtable :basic, :first_name, :last_name, :age, :date_of_birth, :gender, :alive
|
5
5
|
|
6
6
|
jtable :one_to_one, :first_name, :last_name, :age, :date_of_birth, :gender, :alive, {:place => [:address, :city, :state]}
|
7
|
+
|
8
|
+
jtable :custom_attributes, :first_name, :last_name, :date_of_birth
|
9
|
+
|
10
|
+
def jtable_custom_attributes_attribute_date_of_birth
|
11
|
+
self.date_of_birth.strftime("%m/%d/%Y")
|
12
|
+
end
|
7
13
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 2
|
9
|
+
version: 0.2.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Taylor Yelverton
|
@@ -157,6 +157,7 @@ files:
|
|
157
157
|
- spec/fabricators/person.rb
|
158
158
|
- spec/fabricators/place.rb
|
159
159
|
- spec/model_specs/basic_spec.rb
|
160
|
+
- spec/model_specs/custom_attributes_spec.rb
|
160
161
|
- spec/model_specs/one_to_one_spec.rb
|
161
162
|
- spec/spec_helper.rb
|
162
163
|
- spec/support/rails_app/.DS_Store
|
@@ -228,7 +229,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
228
229
|
requirements:
|
229
230
|
- - ">="
|
230
231
|
- !ruby/object:Gem::Version
|
231
|
-
hash:
|
232
|
+
hash: 4306506104062555331
|
232
233
|
segments:
|
233
234
|
- 0
|
234
235
|
version: "0"
|
@@ -252,6 +253,7 @@ test_files:
|
|
252
253
|
- spec/fabricators/person.rb
|
253
254
|
- spec/fabricators/place.rb
|
254
255
|
- spec/model_specs/basic_spec.rb
|
256
|
+
- spec/model_specs/custom_attributes_spec.rb
|
255
257
|
- spec/model_specs/one_to_one_spec.rb
|
256
258
|
- spec/spec_helper.rb
|
257
259
|
- spec/support/rails_app/app/controllers/application_controller.rb
|