multilang-hstore 1.0.0.rc2 → 1.0.0

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.
Files changed (3) hide show
  1. data/README.md +53 -11
  2. data/lib/multilang-hstore/version.rb +1 -1
  3. metadata +4 -4
data/README.md CHANGED
@@ -1,24 +1,37 @@
1
1
  # Multilang-hstore
2
2
 
3
- Multilang is a small translation library for translating database values for Rails 3 using the [Hstore datatype](http://www.postgresql.org/docs/9.0/static/hstore.html).
3
+ Multilang is a small translation library for translating database values for Active Support/Rails 4 using the [Hstore datatype](http://www.postgresql.org/docs/9.0/static/hstore.html).
4
4
 
5
5
  This project is a fork of [artworklv/multilang](https://github.com/artworklv/multilang) with some remarkable differences:
6
6
 
7
7
  * Replaced YAML text fields in favor of Hstore fields.
8
8
  * The translation hash is no longer limited to locales in `I18n.available_locales`.
9
-
10
- It uses [engageis/activerecord-postgres-hstore](https://github.com/engageis/activerecord-postgres-hstore)
9
+ * Support for Rails 3 and Rails 4.
11
10
 
12
11
  ## Installation
13
12
 
14
- You need configure the multilang gem inside your gemfile:
13
+ ### Rails 3
14
+
15
+ The last version of the gem for the Rails 3 series is [0.4](https://github.com/heapsource/multilang-hstore/tree/v0.4). You need configure the multilang gem inside your gemfile:
15
16
 
16
- gem 'multilang-hstore'
17
+ gem 'multilang-hstore', '~> 0.4'
17
18
 
18
- Do not forget to run
19
+ Do not forget to run:
19
20
 
20
21
  bundle install
21
22
 
23
+ ### Rails 4
24
+
25
+ Starting with version `1.0.0`, this gem is intented to be used in Rails 4. If you are migrating an existing project from Rails 3, make sure you read [Migrating to Rails 4](#Migrating-to-Rails-4).
26
+
27
+ You need configure the multilang gem inside your gemfile:
28
+
29
+ gem 'multilang-hstore', '~> 1.0.0'
30
+
31
+ Do not forget to run:
32
+
33
+ bundle install
34
+
22
35
  ## Basic Usage
23
36
 
24
37
  This is a walkthrough with all steps you need to setup multilang translated attributes, including model and migration.
@@ -26,13 +39,13 @@ This is a walkthrough with all steps you need to setup multilang translated attr
26
39
  We're assuming here you want a Post model with some multilang attributes, as outlined below:
27
40
 
28
41
  class Post < ActiveRecord::Base
29
- multilang :title, :accessible => true
42
+ multilang :title
30
43
  end
31
44
 
32
45
  or
33
46
 
34
47
  class Post < ActiveRecord::Base
35
- multilang :title, :description, :required => true, :length => 100, :accessible => true
48
+ multilang :title, :description, :required => true, :length => 100
36
49
  end
37
50
 
38
51
  The multilang translations are stored in the same model attributes (eg. title):
@@ -69,7 +82,7 @@ You may assign attributes through auto generated methods (this methods depend fr
69
82
  post.title_en #=> 'Multilang rocks!'
70
83
  post.title_lv #=> 'Multilang rulle!'
71
84
 
72
- You may use mass assignment on model creation (if :accessible param is defined):
85
+ You may use initialization if needed:
73
86
 
74
87
  Post.new(:title => {:en => 'Multilang rocks!', :lv => 'Multilang rulle!'})
75
88
 
@@ -87,7 +100,7 @@ You may get other translations via attribute translation method:
87
100
 
88
101
  post.title.translation[:lv] #=> 'Multilang rocks!'
89
102
  post.title.translation[:en] #=> 'Multilang rulle!'
90
- post.title.translation.locales #=> [:en, :lv]
103
+ post.title.translation.locales #=> [:en, :lv]
91
104
 
92
105
  If you have incomplete translations, you can get translation from other locale:
93
106
 
@@ -98,6 +111,7 @@ If you have incomplete translations, you can get translation from other locale:
98
111
  The value from "any" method returns value for I18n.current_locale or, if value is empty, it searches through all locales. It takes searching order from I18n.available_locales array.
99
112
 
100
113
  ## Validations
114
+
101
115
  Multilang has some validation features:
102
116
 
103
117
  multilang :title, :length => 100 #define maximal length validator
@@ -122,7 +136,35 @@ Create the role *postgres* if necessary:
122
136
 
123
137
  Finally, you can run your tests:
124
138
 
125
- rspec
139
+ rspec
140
+
141
+ ## Migrating to Rails 4
142
+
143
+ Migrating to Rails 4 and multilang-hstore 1.x is a very straightforward process.
144
+
145
+ ### Deprecated Dependencies
146
+
147
+ Rails 4 has built-in support for `hstore` datatype, so using any dependency to `activerecord-postgres-hstore` must be removed from your Gemfile:
148
+
149
+ ### Mass-Assignment
150
+
151
+ Mass-assignment was deprecated in Rails 4, so it was in our gem. You will receive an error similar to this:
152
+
153
+ Multilang::Exceptions::DeprecationError: :accessible was deprecated starting multilang-hstore >= 1.0.0 which is intended for Rails >= 4.0.0. Check more info about the deprecation of mass-asignment in Rails 4
154
+
155
+ This basically means you are trying to use the option `:accessible` which is deprecated. Removing the option will solve the issue:
156
+
157
+ Before:
158
+
159
+ class Post < ActiveRecord::Base
160
+ multilang :title, :accessible=>true
161
+ end
162
+
163
+ After:
164
+
165
+ class Post < ActiveRecord::Base
166
+ multilang :title
167
+ end
126
168
 
127
169
  ## Bugs and Feedback
128
170
 
@@ -1,3 +1,3 @@
1
1
  module Multilang
2
- VERSION = "1.0.0.rc2"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multilang-hstore
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc2
5
- prerelease: 6
4
+ version: 1.0.0
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Arthur Meinart
@@ -81,9 +81,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
81
  required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  none: false
83
83
  requirements:
84
- - - ! '>'
84
+ - - ! '>='
85
85
  - !ruby/object:Gem::Version
86
- version: 1.3.1
86
+ version: '0'
87
87
  requirements: []
88
88
  rubyforge_project:
89
89
  rubygems_version: 1.8.25