unmantained-activeadmin-plugins / activeadmin-globalize Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Assuming I have the following setup:
form do |f|
f.inputs do
f.translated_inputs do |t|
t.input :title
end
f.translated_inputs do |t|
t.input :description
end
f.input :slug
end
f.actions
end
Now when I create a new entry. All translated values from the second translated_inputs
block will be discarded.
As soon as the record is saved once, it works. But not for the initial save.
I have to group all entries in one translated_inputs
block like so:
form do |f|
f.inputs do |x|
f.translated_inputs do |t|
t.input :title
t.input :description
end
f.input :slug
end
f.actions
end
I have quite a big model and the different translated values are grouped semantically. Due to this behaviour I now have to add a group just for the translated values.
Hello! I have the following model that currently is managed through active admin:
class Item < ActiveRecord::Base
validates :title, presence: true
validates :short_description, presence: true
translates :title, :short_description, fallbacks_for_empty_translations: true
active_admin_translates :title, :short_description do
validates :title, presence: true
validates :short_description, presence: true
end
Recently I had the need to create some items through the seed file and I had the following problem with validations inside declared active_admin_translates.
What I do:
What's going on here? Am I doing something wrong? Also, do I need the 2 validations outside the active_admin_translates block?
I really appreciate any help you can provide.
I've next code:
form do |f| f.semantic_errors *f.object.errors.keys f.inputs 'General' do f.input :active, :as => :boolean f.translated_inputs "Translated fields", switch_locale: false do |t| t.input :title t.input :description, :as => :text end f.has_many :images, display: :panel do |image| image.input :asset, :as => :file image.translated_inputs "globalize", switch_locale: false, display: :panel do |translate_image| translate_image.input :title end end end f.actions end
But the in the (html) result isn't exist "translate_image.input :title", is empty.
PD: sorry by my english.
Hi guys, i'm developing a site with friendly_id, globalize3 and activeadmin-globalize3.
I have a field named :name and I need to generate a slug for him, but the slug is only generated for the current locale.
Is this the correct behaviour? Has some way to work around this and save the slug for all available locales?
Thanks
I have simple application like this
have a model class model.rb
class Post < ActiveRecord::Base
active_admin_translates :title, :text do
validates_presence_of :title
end
end
And appropriate migration
class CreatePosts < ActiveRecord::Migration
def up
create_table :posts do |t|
t.timestamps
end
Post.create_translation_table! title: :string, text: :text
end
def down
drop_table :posts
Post.drop_translation_table!
end
end
Active admin page is configured like this
ActiveAdmin.register Post do
permit_params :title, :text, translations_attributes: [:title, :text, :locale]
index do
translation_status
default_actions
end
form do |f|
f.translated_inputs 'Translated fields', switch_locale: false do |t|
t.input :title
t.input :text
end
f.actions
end
end
When I try to update record, new translation records are created instead updating the old ones causing the AA to display the first value.
I also posted this as a question on Stack Overflow at http://stackoverflow.com/questions/23547401/activeadmin-globalize-does-not-update-records
I'm running into an issue when I try to integrate with the asset pipeline. The CSS and JS files are still being referenced as:
I tried adding the CSS and JS to my precompile list, but this didn't make a difference.
I have a model called Programme
which has a translated attribute called summary
.
When I enable sorting on that column I get an exception:
Mysql2::Error: Unknown column 'summary' in 'order clause': SELECT `programmes`.* FROM `programmes` ORDER BY `summary` desc LIMIT 30 OFFSET 0
I tried to sort by translations_summary
which leads to a similar issue.
def index do
column :title, sortable: false # fallback
column :title, sortable: :title # exception
column :title, sortable: :translations_title #exception
end
Curiously I can access the summary
property of a given programme, but active_admin is not able to sort by this property. Is there a way to include(:translations)
like in the following scope-definition example?
default_scope -> { order('programme_translations.title').includes(:translations) }
Hi, don't know if I'm using it correctly. Here is my code:
ActiveAdmin.register Carousel do
form partial: 'form'
= semantic_form_for [:admin, @carousel] do |f|
- f.translated_inputs "Translated fields" do |t|
t.input :name
= f.actions
undefined method `translated_inputs' for #<Formtastic::FormBuilder:0x007fe1eb3e3c10>
In the current activeadmin master (9132da6) "form_buffer" in lib/active_admin/views/components/active_admin_form.rb has been removed. (raise "'form_buffers' has been removed from ActiveAdmin::FormBuilder, please read https://github.com/activeadmin/activeadmin/blob/master/docs/5-forms.md for details.") Therefore, activeadmin-globalize "f.translated_inputs" function does not work anymore.
# app/admin.project.rb
ActiveAdmin.register Project do
form do |f|
f.translated_inputs do |t|
t.input :title
end
end
end
# config/locales/ru.yml
ru:
activerecord:
attributes:
project:
title: Название
I'm expecting label on input field to be 'Title' for English tab and 'Название' for Russian tab. Currently it shows 'Title' for both tabs.
Could you help me to solve the problem?
When deploying to heroku, I get the following error:
ActionView::Template::Error (active_admin/active_admin_globalize3.css isn't precompiled)
I already added the following lines to my application.rb:
config.assets.enabled = true
config.assets.precompile += ['active_admin.css', 'active_admin.js', 'active_admin_globalize3.css']
But I still get the error above. Rails 3.2.13, Ruby 2.0.0
In admin panel I have default Deutsche translation. How I can set default open tab English for example?
Hi guys, first I want to say THX for this gem! It saved me ages, is good designed and a pleasure to work with.
Today I came up with something strange, which maybe also is interesting for you. There are also records created for empty languages (all fields empty). As I want to give the users the ability to switch languages (if there are any other available) its a hassle to find out, which languages are filled and which not.
So I implemented an easy solution. A before_filter which removes empty languages form the params hash, or marks empty languages which existed (has han id) with the flag '_destroy' => '1'
. Where as the first part works greate. The second part with the '_destory' => '1'
gets ignored. I don't know why, because you set allow_destroy: true
# activeadmin-globalize3 / lib / active_admin / globalize3 / active_record_extension.rb
attr_accessible :translations_attributes
accepts_nested_attributes_for :translations, allow_destroy: true
Here my code:
# Inside an own active_admin page
ActiveAdmin.register MyModel do
before_filter :remove_or_mark_empty_translations, :only => [:update, :create]
controller do
private
def remove_or_mark_empty_translations
params[:requisition][:translations_attributes].each do |t|
# iterates through the fields and checks if they are empty
# the first two entries (id and locale) are ignored
if !(t.last.map { |k,v| v.empty? ? true : false }[2..-1]).include?(false)
if t.last[:id].empty?
# If id is also empty, remove from params
# works fine!
params[:requisition][:translations_attributes].delete(t.first)
else
# otherwise mark to destroy
# FIXME : seems to be ignored
params[:requisition][:translations_attributes][t.first]['_destroy'] = '1'
end
end
end
end
end
end
Have you any ideas or better solutions?
PS: to remove empty translation rows improves also the view helper translation_status ;)
When click on a language Tab a route error is displayed:
Started GET "/admin/people/asdfasdf-asdf/.locale-es" for 127.0.0.1 at 2014-06-26 17:36:13 -0300
ActionController::RoutingError (No route matches [GET] "/admin/people/asdfasdf-asdf/.locale-es"):
Hello, using:
active_admin_translates :title, :description do
validates_presence_of :title
end
activeadmin validates presence of title in all languages, is there a way to pass validation if one language (at least) is filled?
Thank you.
Hi,
Found your gem through a Google search and have been playing with it, pretty smooth sailing so far. One thing I noticed was that if a translation has validators attached to it, and if validation fails, the form is not saved (create and update) and no validation errors are shown.
Very simple example:
class Page < ActiveRecord::Base
# attr_accessible :title, :body
# translates :title, :body
active_admin_translates :title, :body do
validates_presence_of :title, :body
end
end
Leaving either title or body empty keeps the Model from being created / update, as intended, but no validation errors are shown. Also, values are not persisted (i.e. emptying title on an already created model and submitting will show a form with the old title value and no errors).
Regards,
Lorenz
Hi @stefanoverna
I use you gem for an app which works with Rails3. As ActiveAdmin is not jet really stable on rails 4 and also other gems we are useing, I dont want to upgrade to Rails4 jet.
Now the globalize gem changed the name and also you already updated it. That's good. The only problem now is, that you have as the dependency globalize version 4:
# activeadmin-globalize.gemspec
s.add_dependency "globalize", '~> 4.0.0'
using Rails 3 it is recommended to use globalize version 3.1.0
gem 'globalize', '~> 3.1.0'
It would be great, if you could tag a version which uses Version 3. The features should be the same (https://github.com/globalize/globalize#installation). Otherwise I have to fork the gem and change it manually.
THX!
I have a custom form using the activeadmin-globalize3 translated_inputs
method. Everything looks good except the duplicate field for title
. Any idea why this is produced?
The admin register messages.rb
ActiveAdmin.register Message do
form :partial => 'form'
end
The code in _form.html.haml
= semantic_form_for [:admin, @message], :builder => ActiveAdmin::FormBuilder do |f|
- f.translated_inputs do |t|
= t.input :title
= t.input :content
= f.actions do
= f.action :submit
%li.cancel
= link_to I18n.t('active_admin.cancel'), {:action => "index"}
I also tried to use the original Formtastic formbuilder instead of ActiveAdmin::FormBuilder, but with that I had no access to the translated_inputs
method. Any help much appreciated!
I have 4 translation in my site and 4 tabs for them. When I try create news
for example with one translation and I save it it also create 3 another as ""
strings.
How I can save just not void translations?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.