Tips for Writing a Good CV / Résumé May 20, 2020
Due to COVID-19, not many companies are hiring at the moment. The company I work for therefore is in a very fortunate position to still be…
Web applications normally have many forms. Building forms is always a mind-boggling task because it involves repetition and chaos.
As I am using Rails 3, and the Rails 3 port of Formtastic isn’t complete yet, I thought I’d just use the plain vanilla Rails built-in form helper.
First of all, I am using Haml instead of ERb. Already, I got the out-of-box clean looking Haml markup.
Some of you might not be aware of the fact that Rails’ built-in form helper already does i18n support.
If you have the following form:
-form_for(@post) do |f| =f.label :title =f.text_field :title =f.label :body =f.text_area :body =f.submit
You can simply translate the labels as such in
helpers: label: post: title: "Post Title" body: "Post Content"
Better yet, I am using r18n instead of i18n, so I can instead translate them in
helpers: label: post: title: Post Title body: Post Content
Alternatively, instead of placing the translation strings under
helpers.label, you may place them directly under your models, i.e.