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
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Tamedia</title> | |
<meta name="description" content="Tamedia Landing page"> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> | |
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script> | |
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script> |
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
firstName | lastName | phoneNumber | Data1 | Data2 | ||
---|---|---|---|---|---|---|
John | Doe | [email protected] | 0123456789 | X | Y | |
Jane | Doe | [email protected] | 9876543210 | Y | Z | |
James | Bond | [email protected] | 0612345678 | K | Y |
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
task migrate_file_uploads_from_database_to_amazon: :environment do | |
Document.find_each do |d| # Document is our ActiveRecord model containing the `data` binary column (bytea Postgres type) | |
next if ENV['ID'] && d.id.to_s != ENV['ID'] # be able to say `ID=225 rake migrate_file_uploads_from_database_to_amazon` to process single record | |
next unless d.data # d.data is a binary column we were storing files at | |
print d.id | |
dir = "tmp/#{d.id}" | |
Dir.mkdir(dir) unless Dir.exist?(dir) |
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
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
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
class NestedAttributesUniquenessValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
value = value.reject(&:_destroy) # let's ignore the items to be destroyed here | |
unless value.map(&options[:field]).uniq.size == value.size | |
record.errors[attribute] << "must be unique" | |
duplicates = value - Hash[value.map{|obj| [obj[options[:field]], obj]}].values | |
duplicates.each { |obj| obj.errors[options[:field]] << "has already been taken" } | |
end | |
end | |
end |