# Anchor
click_link 'Save'
# Button
click_button 'awesome'
# Both aboveIn attempting to install Ruby with rbenv, I ran into the following build failures:
BUILD FAILED (macOS 11.2.3 using ruby-build 20210423)
Inspect or clean up the working tree at /var/folders/58/16lnyx815c183j6wzcbl_thc0000gn/T/ruby-build.20210426232453.81982.XfAg0C
Results logged to /var/folders/58/16lnyx815c183j6wzcbl_thc0000gn/T/ruby-build.20210426232453.81982.log
Last 10 log lines:
^
This file contains hidden or 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
| FROM ruby:2.3.1 | |
| # Install dependencies | |
| RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs | |
| # Set an environment variable where the Rails app is installed to inside of Docker image: | |
| ENV RAILS_ROOT /var/www/app_name | |
| RUN mkdir -p $RAILS_ROOT | |
| # Set working directory, where the commands will be ran: |
This file contains hidden or 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
| .git | |
| .gitignore | |
| /doc | |
| .yardoc | |
| coverage | |
| jsdoc | |
| /tmp | |
| /log | |
| Dockerfile | |
| Dockerfile.prod |
This file contains hidden or 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
| Backup: | |
| docker exec -t -u postgres your-db-container pg_dumpall -c > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql | |
| Restore: | |
| cat your_dump.sql | docker exec -i your-db-container psql -Upostgres |
This file contains hidden or 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
| # Assumes the database container is named 'db' | |
| DOCKER_DB_NAME="$(docker-compose ps -q db)" | |
| DB_HOSTNAME=db | |
| DB_USER=postgres | |
| LOCAL_DUMP_PATH="path/to/local.dump" | |
| docker-compose up -d db | |
| docker exec -i "${DOCKER_DB_NAME}" pg_restore -C --clean --no-acl --no-owner -U "${DB_USER}" -d "${DB_HOSTNAME}" < "${LOCAL_DUMP_PATH}" | |
| docker-compose stop db |
This file contains hidden or 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
| # rails config needs `force_ssl` | |
| # example: | |
| # Force all access to the app over SSL, use Strict-Transport-Security, | |
| # and use secure cookies. | |
| # config.force_ssl = true | |
| # and rails needs some headers to be set, otherwise will be trapped in a redirect loop | |
| # nginx config for headers: | |
| # proxy_set_header X-Real-IP $remote_addr; | |
| # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
| # proxy_set_header X-Forwarded-Proto https; |
This file contains hidden or 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
| HTTP status code symbols for Rails | |
| Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings. | |
| Status Code Symbol | |
| 1xx Informational | |
| 100 :continue | |
| 101 :switching_protocols | |
| 102 :processing |
This file contains hidden or 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
| require 'nokogiri' | |
| require 'open-uri' | |
| # Get a Nokogiri::HTML:Document for the page we're interested in... | |
| doc = Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove')) | |
| # Do funky things with it using Nokogiri::XML::Node methods... | |
| #### |
By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:
/people/6
But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.
NewerOlder