-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
path for form helper #105
Comments
In general, that fact that the get '/something' => 'my_controller#my_action', as: :i18n_backend_active_record_translation most likely it will work without 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 |
I changed
`Translation = I18n::Backend::ActiveRecord::Translation`
In the initializer to:
```
class Translation < I18n::Backend::ActiveRecord::Translation
end
```
An now it works as expected.
I think it’s wise to change this in the default `I18n_active_record.erb`
Regards,
Didier
From: Tim Masliuchenko <notifications@github.com>
Sent: Tuesday, May 19, 2020 2:18 AM
To: svenfuchs/i18n-active_record <i18n-active_record@noreply.github.com>
Cc: D4v1dW3bb <didier.geheniau@feas.net>; Author <author@noreply.github.com>
Subject: Re: [svenfuchs/i18n-active_record] path for form helper (#105)
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.
—
You are receiving this because you authored the thread.
Reply to this email directly, <#105 (comment)> view it on GitHub, or <https://github.com/notifications/unsubscribe-auth/AB2SQHR62CE47FTBNGYZNXDRSI6C7ANCNFSM4NENESQQ> unsubscribe. <https://github.com/notifications/beacon/AB2SQHWM3PXXFMSGD4CJZSLRSI6C7A5CNFSM4NENESQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEWLSQFA.gif>
|
It is not recomennded to keep It is expected 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. |
You can use But I am going to revisit |
So how exactly is this done? |
The easiest way is to have something like this in the post '/some_path', to: 'my_controller#my_action', as: 'i18n_backend_active_record_translation' But the custom model should be more convinient |
When making a form i got an error:
ActionView::Template::Error (undefined method 'i18n_backend_active_record_translation_path' for #<#<Class:0x00007f04a9399298>:0x00007f04917462c8>):
when adding
url: translations_path
to the form it worked again.I think this originates from the initializer line:
Translation = I18n::Backend::ActiveRecord::Translation
There for
Translation.name
andTranslation.sti_name
is `I18n::Backend::ActiveRecord::Translation'So when you call a form without an url parameter
i18n_backend_active_record_translation_path
is automatically generated for url.Would be nice to ad a comment in the readme to put
add "url: <translation_view_dir>_path" to form_with
The text was updated successfully, but these errors were encountered: