Comments (7)
In general, that fact that the i18n_backend_active_record_translation_path
is not defined but the translations_path
is has nothing to do with the initializer.
translations_path
works only because you have an entry in routes.rb
that defines a route named translations
, so if you add something like
get '/something' => 'my_controller#my_action', as: :i18n_backend_active_record_translation
most likely it will work without url: translations_path
You can also try
class Translation < I18n::Backend::ActiveRecord::Translation
end
Adding the note about the path helper might be confusing because this gem doesn't really add routes and controllers and acts purely as a backend for I18n
gem.
from i18n-active_record.
from i18n-active_record.
It is not recomennded to keep class Translation < I18n::Backend::ActiveRecord::Translation
in the initializer, it should be in app/models/translation.rb
Basically this way we define our own AR model but inherit from the model from the gem.
I shared that just to illustrate that the issue wasn't really related to the initializer.
It is expected that I18n::Backend::ActiveRecord::Translation
returns i18n_backend_active_record_translation_path
.
Usage of the model in helpers like form_for
or link_to
is not supported because this gem doesn't provide any controllers, routes to handle that.
from i18n-active_record.
It is expected that I18n::Backend::ActiveRecord::Translation returns i18n_backend_active_record_translation_path.
Usage of the model in helpers like form_for or link_to is not supported because this gem doesn't provide any controllers, routes to handle that.
The gem does not provide it but it's expected the users of the gem are going to use it. Their not going to fill the translation table by hand. so they will need to make controllers, views and routes. Therefor the translation table should act like every other model whether it's installed by a gem or the programmer implements it himself.
from i18n-active_record.
You can use i18n_backend_active_record_translation
name in your routes because this is what the model generates.
But I am going to revisit Translation = I18n::Backend::ActiveRecord::Translation
part in the initializer and probably include class Translation < I18n::Backend::ActiveRecord::Translation
model instead.
from i18n-active_record.
You can use
i18n_backend_active_record_translation
name in your routes because this is what the model generates.
So how exactly is this done?
from i18n-active_record.
You can use
i18n_backend_active_record_translation
name in your routes because this is what the model generates.So how exactly is this done?
The easiest way is to have something like this in the routes.rb
:
post '/some_path', to: 'my_controller#my_action', as: 'i18n_backend_active_record_translation'
But the custom model should be more convinient
from i18n-active_record.
Related Issues (20)
- undefined method `map' for "translation missing: en-US.i18n.plural.keys":String HOT 4
- lookup method not reusing @translations HOT 12
- Error encountered when creating a DB HOT 1
- Generator with class name in a module produces invalid migration HOT 1
- Falling docker build HOT 2
- Add a changelog HOT 4
- Documentation or Removal of proc handling mechanism HOT 1
- Add additional config options `fallback_to_default_locale` and `raise_exception_on_missing` HOT 3
- cache_translations = true not respected if translations table is empty HOT 2
- Memoization stopped working on upgrading to 1.0.0 HOT 7
- Breaks on latest i18n HOT 2
- Configuring ActiveRecord backend as first in chain causes errors during initialization HOT 3
- rails 7.0.3.1: Psych::DisallowedClass: Tried to load unspecified class: Symbol HOT 1
- Update example article for Rails 5.1 HOT 3
- Missing translations with default values as option HOT 1
- Code reloading with Zeitwerk HOT 4
- Issue with singular vs plural look up HOT 2
- Translations with interpolations break on rails 7.1+ HOT 3
- After upgrade to Rails 7.1, translations that end in a colon return a Hash, not a String HOT 25
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from i18n-active_record.