Skip to content

Instantly share code, notes, and snippets.

Any form, no object, just data to send, all you need is the target action route
form_with url: posts_path do |form|
Form for object, you add it **generically** to the tag. But `@post` still needs to be defined in the controller action
form_with scope: :post, url: posts_path do |form|
Form for object, safe for both post and patch paths. define `@post` in the controller action
form_with(model: @post) do |form|
Form for object, but you want to be lazy and not define `@post` in the controller action
@dvodvo
dvodvo / gist:c8aad4e49a303c636aea384cbdae9007
Last active June 2, 2022 05:41
quick and dirty I18n with Mobility
This is intended as a 'minimal amount of steps' to get Mobility running properly
• rails generate mobility:install
• edit `config/initializers/mobility.rb`
- uncomment `dirty`</li>
- uncomment `locale_accessors` and set desired locales
• rails db:migrate
• setup model
extend Mobility
translates :synopsis, type: :string
@dvodvo
dvodvo / gist:f7e3fac76e3db3d4adbc37448a8b709f
Last active April 11, 2022 06:06
multiple database application and i18n with Mobility
Until further notice, i.e. a documented mechanism to run **multiple backend** for an application, the following is a tactical approach to leveraging the Mobility gem.
Motive: consideration of different focus of data - assume global(or central) and local(or decentral) - leads to different polyglot and data requirements locally. One size does not necessarily fit all well.
the key_value backend has its advantages and inconveniences in this context.
*Advantages*
• easily extendible
• good for high volume of translated data
( the other advantages documented here remain true https://dejimata.com/2017/3/3/translating-with-mobility )
*Inconveniences*
• all locale data converges to a single table, which would service the multiple databases of the application
@dvodvo
dvodvo / muggia_centro.json
Created February 14, 2022 09:07
muggia centro
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dvodvo
dvodvo / muggia_est.json
Last active February 14, 2022 10:40
muggia est
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dvodvo
dvodvo / muggia_ovest.json
Created February 14, 2022 10:14
muggia ovest
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dvodvo
dvodvo / cedarchis.geojson
Last active February 14, 2022 10:39
Arta - Cedarchis
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dvodvo
dvodvo / cabia.geojson
Created February 14, 2022 10:25
arta - cabia
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dvodvo
dvodvo / piano_d_arta.geojson
Created February 14, 2022 10:37
Arta - Piano d'arta
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.