acts_as_select 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +10 -8
- data/lib/acts_as_select/selection.rb +3 -3
- data/lib/acts_as_select/version.rb +1 -1
- metadata +61 -47
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# ActsAsSelect
|
2
2
|
|
3
|
-
|
3
|
+
acts_as_select creates a select style for each column in the database (except the primary key) and returns a 2d array
|
4
|
+
in a form suitable for use in a selection drop down (hence the name)
|
4
5
|
|
5
6
|
## Installation
|
6
7
|
|
@@ -18,16 +19,17 @@ Or install it yourself as:
|
|
18
19
|
|
19
20
|
## Usage
|
20
21
|
|
21
|
-
|
22
|
+
Include acts_as_select in your model file. This makes all columns accessible by calling select_<column_name>
|
22
23
|
|
23
|
-
|
24
|
+
Example:
|
25
|
+
class Dummy < ActiveRecord::Base
|
26
|
+
acts_as_select
|
27
|
+
end
|
24
28
|
|
25
|
-
|
26
|
-
|
27
|
-
end
|
29
|
+
If dummy had a name and description defined in the database, this would create
|
30
|
+
the methods: select_description, select_name
|
28
31
|
|
29
|
-
|
30
|
-
which will return 2D arrays with the column and primary key details.
|
32
|
+
These can then be used anywhere you need a select.
|
31
33
|
|
32
34
|
## Contributing
|
33
35
|
|
@@ -2,10 +2,10 @@ module ActsAsSelect
|
|
2
2
|
def acts_as_select
|
3
3
|
column_names.each do |field|
|
4
4
|
class_eval %Q(
|
5
|
-
if Rails::
|
6
|
-
scope :select_#{field}_objects, lambda {{:select => "#{field}, \#{primary_key}"}}
|
7
|
-
else
|
5
|
+
if case Rails::VERSION_MAJOR < 3
|
8
6
|
named_scope :select_#{field}_objects, lambda {{:select => "#{field}, \#{primary_key}"}}
|
7
|
+
else
|
8
|
+
scope :select_#{field}_objects, lambda { select("#{field}, \#{primary_key}") }
|
9
9
|
end
|
10
10
|
|
11
11
|
class << self
|
metadata
CHANGED
@@ -1,56 +1,61 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_select
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Paul McKibbin
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2014-12-16 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: bundler
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '1.3'
|
22
|
-
type: :development
|
23
22
|
prerelease: false
|
24
|
-
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
24
|
none: false
|
26
|
-
requirements:
|
25
|
+
requirements:
|
27
26
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 9
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 3
|
32
|
+
version: "1.3"
|
38
33
|
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rake
|
39
37
|
prerelease: false
|
40
|
-
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
39
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id002
|
49
|
+
description: Creation of automatic selection suitable for drop downs from all column fields in an ActiveRecord table
|
50
|
+
email:
|
49
51
|
- pmckibbin@gmail.com
|
50
52
|
executables: []
|
53
|
+
|
51
54
|
extensions: []
|
55
|
+
|
52
56
|
extra_rdoc_files: []
|
53
|
-
|
57
|
+
|
58
|
+
files:
|
54
59
|
- .gitignore
|
55
60
|
- Gemfile
|
56
61
|
- LICENSE.txt
|
@@ -61,28 +66,37 @@ files:
|
|
61
66
|
- lib/acts_as_select/selection.rb
|
62
67
|
- lib/acts_as_select/version.rb
|
63
68
|
homepage: http://blackrat.org
|
64
|
-
licenses:
|
69
|
+
licenses:
|
65
70
|
- MIT
|
66
71
|
post_install_message:
|
67
72
|
rdoc_options: []
|
68
|
-
|
73
|
+
|
74
|
+
require_paths:
|
69
75
|
- lib
|
70
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
77
|
none: false
|
72
|
-
requirements:
|
73
|
-
- -
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
|
76
|
-
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
hash: 3
|
82
|
+
segments:
|
83
|
+
- 0
|
84
|
+
version: "0"
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
86
|
none: false
|
78
|
-
requirements:
|
79
|
-
- -
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
hash: 3
|
91
|
+
segments:
|
92
|
+
- 0
|
93
|
+
version: "0"
|
82
94
|
requirements: []
|
95
|
+
|
83
96
|
rubyforge_project:
|
84
97
|
rubygems_version: 1.8.25
|
85
98
|
signing_key:
|
86
99
|
specification_version: 3
|
87
100
|
summary: Automated selection for Activerecord Tables
|
88
101
|
test_files: []
|
102
|
+
|