This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A utility method for idempotent writes with ActiveRecord. | |
# Add a unique Postgres or MySQL index for the fields in `unique_attributes`. | |
# The method will look attempt to create a record. If it fails due to a | |
# unique index validation, it will update the existing record with the same | |
# unique attributes. | |
# Inpired by `create_or_find_by` in Rails 6, but serves a different use case. | |
# https://bigbinary.com/blog/rails-6-adds-create_or_find_by | |
class CreateOrUpdateUnique |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:javascript | |
$(document).ready(function() { | |
window.loadIngredientSuggestionsEditor(#{@ingredients}); | |
}); | |
%h1 Edit ingredient suggestions | |
#js-ingredient-suggestions-editor |