acts_as_select 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +8 -10
- data/lib/acts_as_select/selection.rb +5 -1
- data/lib/acts_as_select/version.rb +1 -1
- data/lib/acts_as_select.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# ActsAsSelect
|
2
2
|
|
3
|
-
|
4
|
-
in a form suitable for use in a selection drop down (hence the name)
|
3
|
+
Creation of automatic selection-like 2D arrays suitable for drop downs from all column fields in an ActiveRecord table
|
5
4
|
|
6
5
|
## Installation
|
7
6
|
|
@@ -19,17 +18,16 @@ Or install it yourself as:
|
|
19
18
|
|
20
19
|
## Usage
|
21
20
|
|
22
|
-
|
21
|
+
In the ActiveRecord model for the reference data, add in acts_as_select to allow all fields to be select items
|
23
22
|
|
24
|
-
|
25
|
-
class Dummy < ActiveRecord::Base
|
26
|
-
acts_as_select
|
27
|
-
end
|
23
|
+
e.g.
|
28
24
|
|
29
|
-
|
30
|
-
|
25
|
+
class Dummy < ActiveRecord::Base
|
26
|
+
acts_as_select
|
27
|
+
end
|
31
28
|
|
32
|
-
|
29
|
+
If the Dummy model contains the columns name and description, this will create name_select and description_select methods
|
30
|
+
which will return 2D arrays with the column and primary key details.
|
33
31
|
|
34
32
|
## Contributing
|
35
33
|
|
@@ -2,7 +2,11 @@ module ActsAsSelect
|
|
2
2
|
def acts_as_select
|
3
3
|
column_names.each do |field|
|
4
4
|
class_eval %Q(
|
5
|
-
|
5
|
+
if Rails::VERSION::MAJOR > 2
|
6
|
+
scope :select_#{field}_objects, lambda {{:select => "#{field}, \#{primary_key}"}}
|
7
|
+
else
|
8
|
+
named_scope :select_#{field}_objects, lambda {{:select => "#{field}, \#{primary_key}"}}
|
9
|
+
end
|
6
10
|
|
7
11
|
class << self
|
8
12
|
def #{field}_select
|
data/lib/acts_as_select.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_select
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
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: 2013-07-
|
12
|
+
date: 2013-07-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|