Skip to content

Commit ccaa2ad

Browse files
committed
Merge branch 'feature/rails4-only' into develop
2 parents e741bea + bc2a06c commit ccaa2ad

28 files changed

+193
-167
lines changed

Gemfile

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,21 @@ gemspec
1414
# gem 'debugger'
1515

1616
# Gems used by the dummy application
17-
group :assets do
18-
gem 'sass-rails', '~> 3.2.3'
19-
gem 'coffee-rails', '~> 3.2.1'
17+
gem 'rails', '~> 4.0.0'
18+
gem 'sass-rails', '~> 4.0.2'
19+
gem 'coffee-rails'
2020

21-
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
22-
gem 'therubyracer', platforms: :ruby
23-
24-
gem 'uglifier', '>= 1.0.3'
25-
end
21+
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
22+
gem 'therubyracer', platforms: :ruby
23+
gem 'uglifier'
2624

2725
# jquery-rails is
2826
gem 'jquery-rails'
2927

28+
# Fetch activeadmin from github until is released
29+
gem 'activeadmin', github: 'activeadmin'
30+
gem 'devise'
31+
3032
group :test do
3133
gem 'sqlite3', '~> 1.3.5'
3234
gem 'rspec-rails', '~> 2.14.0'

README.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
# ActiveAdmin::Globalize
2+
23
Makes it easy to translate your resource fields.
34

5+
[![Gem Version](https://badge.fury.io/rb/activeadmin-globalize.svg)](http://badge.fury.io/rb/activeadmin-globalize)
6+
[![Build Status](https://travis-ci.org/fabn/activeadmin-globalize.svg?branch=develop)](https://travis-ci.org/fabn/activeadmin-globalize)
7+
48
## Installation
59

10+
This version targets Rails 4 and greater and ActiveAdmin >= 1.0.0.pre.
11+
612
```ruby
7-
gem 'activeadmin-globalize', '~> 0.6.3'
13+
gem 'activeadmin-globalize', '~> 1.0.0.pre', github: 'fabn/activeadmin-globalize', branch: 'develop'
814
```
915

10-
This version targets Rails 3.2.x only and ActiveAdmin ~> 0.6.3.
16+
As soon as ActiveAdmin 1.x is released to rubygems, I'll release the gem with no need for github dependency. See
17+
[this issue](https://github.com/activeadmin/activeadmin/issues/3448) for more details.
18+
19+
Previous version with support for Rails 3 is maintained in branch [support/0.6.x](https://github.com/fabn/activeadmin-globalize/tree/support/0.6.x)
1120

1221
## Your model
1322

@@ -19,6 +28,10 @@ end
1928
## Editor configuration
2029

2130
```ruby
31+
32+
# For usage with strong parameters you'll need to permit them
33+
permit_params translations_attributes: [:id, :locale, :title, :content, :_destroy]
34+
2235
index do
2336
# textual translation status
2437
translation_status
@@ -39,19 +52,17 @@ end
3952
```
4053
If `switch_locale` is set, each tab will be rendered switching locale.
4154

42-
## Friendly ID
43-
44-
If you want to use Friendly ID together with Globalize, please take a look
45-
at the `activeadmin-seo` gem.
4655

4756
## Hints
4857

4958
To use the dashed locale keys as 'pt-BR' or 'pt-PT' you need to convert a string
5059
to symbol (in application.rb)
5160

61+
```ruby
5262
config.i18n.available_locales = [:en, :it, :de, :es, :"pt-BR"]
63+
```
5364

5465
## Credits
5566

5667
This work is based on original idea by [@stefanoverna](https://github.com/stefanoverna/activeadmin-globalize),
57-
I needed it for AA 0.6.x so I forked the original project.
68+
I needed it for AA 0.6.x so I forked the original project and expanded it with more features.

activeadmin-globalize.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Gem::Specification.new do |s|
1515

1616
s.files = Dir['{app,config,db,lib}/**/*'] + %w(MIT-LICENSE README.md)
1717

18-
s.add_dependency 'activeadmin', '~> 0.6.3'
19-
s.add_dependency 'globalize', '~> 3.0.4'
18+
s.add_dependency 'activeadmin', '~> 1.0.0.pre'
19+
s.add_dependency 'globalize', '~> 4.0'
2020

2121
# development dependencies
2222
s.add_development_dependency 'bundler', '>= 1.6.1'

app/assets/stylesheets/active_admin/active_admin_globalize_flags.css.sass

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
width: 16px
77
height: 11px
88
vertical-align: middle
9-
background: url(active_admin_image_path('flags.png')) no-repeat
9+
background: image-url('active_admin/flags.png') no-repeat
1010
&.flag-ar // originally flag-ae
1111
background-position: -16px 0
1212
&.flag-br

lib/active_admin/globalize/attributes_table_extension.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ def translated_row(*args, &block)
7474

7575
# @return [Boolean] true iff the field is translatable
7676
def translatable?(field)
77-
@record.class.translates? &&
78-
@record.class.translated_attribute_names.include?(field.to_sym)
77+
@resource_class.translates? &&
78+
@resource_class.translated_attribute_names.include?(field.to_sym)
7979
end
8080

8181
# Build a tag for each field translation with appropriate css classes to make javascript working
@@ -131,7 +131,7 @@ def inline_locale_selectors
131131
end
132132

133133
def available_translations
134-
@record_translations ||= @record.translations.order(:locale)
134+
@record_translations ||= @collection.first.translations.order(:locale)
135135
end
136136

137137
end

lib/active_admin/globalize/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module ActiveAdmin
22
module Globalize
3-
VERSION = '0.6.3'
3+
VERSION = '1.0.0.pre'
44
end
55
end
66

spec/dummy/app/admin/articles.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
ActiveAdmin.register Article do
22

3+
permit_params :title, :body
4+
35
index do
46
id_column
57
column :title

spec/dummy/app/admin/dashboard.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
ActiveAdmin.register_page "Dashboard" do
22

3-
menu :priority => 1, :label => proc{ I18n.t("active_admin.dashboard") }
3+
menu priority: 1, label: proc{ I18n.t("active_admin.dashboard") }
44

5-
content :title => proc{ I18n.t("active_admin.dashboard") } do
6-
div :class => "blank_slate_container", :id => "dashboard_default_message" do
7-
span :class => "blank_slate" do
5+
content title: proc{ I18n.t("active_admin.dashboard") } do
6+
div class: "blank_slate_container", id: "dashboard_default_message" do
7+
span class: "blank_slate" do
88
span I18n.t("active_admin.dashboard_welcome.welcome")
99
small I18n.t("active_admin.dashboard_welcome.call_to_action")
1010
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#= require active_admin/base

spec/dummy/app/models/admin_user.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,4 @@ class AdminUser < ActiveRecord::Base
33
# :confirmable, :lockable, :timeoutable and :omniauthable
44
devise :database_authenticatable,
55
:recoverable, :rememberable, :trackable, :validatable
6-
7-
# Setup accessible (or protected) attributes for your model
8-
attr_accessible :email, :password, :password_confirmation, :remember_me
9-
# attr_accessible :title, :body
106
end

0 commit comments

Comments
 (0)