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
Remove Ohm monkey patch and include Padrino::Ohm::Validator #1196
Remove Ohm monkey patch and include Padrino::Ohm::Validator #1196
Conversation
Thanks @lastcanal! Thoughts @skade @ujifgc? |
Ohm has accepted my pull request and has released 1.3.0. This exposes Model.attributes and allows the admin generator to get a list of attributes from Ohm models. This covers off the second half of the monkey patch. I have updated the Ohm dependancy to be ~> 1.3.0 |
@lastcanal thanks for the update!.. I was glad to see that popping up on Ohm 1.3.0 :). Thanks!.. As for I reckon that would make it simpler and more predictable. Thoughts? |
I'm in favor or dropping It would certainly be possible to map all of the current padrino admin ORM translations to look something like this: https://gist.github.com/lastcanal/5281134. That way in the future if someone has a more specific translation for 'not_decimal' then it can be included. |
Good, let's drop validations then. I'm in favour of adding the translations to Padrino's I18n files directly (we're already mapping AR/AM, so it's fine if we do Ohm too). The only thing we need to look after is Ohm errors coming like |
I now have Ohm model errors translating without the extra validations module. I've updated I have also included translations for Ohm's errors in the admin orm locales. Here is the script I used to do the conversion. I haven't included the script in the source tree. The rake task I was referring to would be for building translation yaml files from Ohm models. Similar to how they are being generated for ActiveRecord with this task. Currently this patch will only look for Ohm errors in |
This looks good I think based on #1148 so merging this in. |
Remove Ohm monkey patch and include Padrino::Ohm::Validator
Thanks @lastcanal for your help with this. |
This removes the monkey patch to Ohm and includes a module in
./lib/padrino_ohm_validations.rb
when a project is generated.Padrino::Ohm::Validations
overrides the error names inScrivener::Validations
to match Active Model's errors. This module is included by default for generated ohm models.see this 3 year old ohm issue for more info
#1148