Reputation: 9335
I'm working on a bilingual Rails application. I have a model Application
, which represents an applicant to a certain course (if a person wants to participate, he/she fills in the application form, and that is saved into the database). The problem is, the form should look a bit different in English than in Croatian (those are the 2 languages). I would normally have to tables for this purpose, but the difference is really small, so I don't want to.
So, this means that I have to have different validations depending on whether the applicant submitted the croatian or the english form. Is there a way I can do that?
Upvotes: 1
Views: 61
Reputation: 5437
You can use if
or unless
option for validation
validates :something, presence: true, if: ->(){ language == "en" }
language
could be virtual attribute defined in your model which you can pass in form params
Upvotes: 1