acts_as_select 0.0.1 → 0.0.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 CHANGED
@@ -1,7 +1,6 @@
1
1
  # ActsAsSelect
2
2
 
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)
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
- Include acts_as_select in your model file. This makes all columns accessible by calling select_<column_name>
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
- Example:
25
- class Dummy < ActiveRecord::Base
26
- acts_as_select
27
- end
23
+ e.g.
28
24
 
29
- If dummy had a name and description defined in the database, this would create
30
- the methods: select_description, select_name
25
+ class Dummy < ActiveRecord::Base
26
+ acts_as_select
27
+ end
31
28
 
32
- These can then be used anywhere you need a select.
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
- scope :select_#{field}_objects, lambda {{:select => "#{field}, \#{primary_key}"}}
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
@@ -1,3 +1,3 @@
1
1
  module ActsAsSelect
2
- VERSION = '0.0.1'
2
+ VERSION = "0.0.2"
3
3
  end
@@ -3,4 +3,4 @@ require 'acts_as_select/selection'
3
3
 
4
4
  class ActiveRecord::Base
5
5
  extend ActsAsSelect
6
- end
6
+ end
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.1
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-02 00:00:00.000000000 Z
12
+ date: 2013-07-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler