- Generate new rails app using
--webpack
flag
rails new myApp --webpack=vue
Note:
- You can use
--webpack=angular
for angular application and--webpack=react
for react.
# spec/rails_helper.rb | |
require_relative 'support/webpack_test_helper.rb' | |
# ... | |
config.before(:suite) do | |
# Compile webpack if necessary. | |
# Only runs if checksum of JS files has changed | |
WebpackTestHelper.compile_webpack_assets | |
end |
# This makes sure Chrome is always up to date in your test suite | |
# On average this adds about 10 seconds to your build suite | |
# Be sure to use Ubuntu 14.04 (Trusty) in the CircleCI's OS setting (Settings > Build Environment) | |
dependencies: | |
pre: | |
- curl -L -o google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb | |
- sudo dpkg -i google-chrome.deb | |
- sudo sed -i 's|HERE/chrome\"|HERE/chrome\" --disable-setuid-sandbox|g' /opt/google/chrome/google-chrome | |
- rm google-chrome.deb |
# Build an image | |
docker build -t <image_name> <dockerfile_path> | |
# Run a container | |
docker run -d -p <host_port>:<container_port> --name <container_name> <image_name> | |
PS1: In this sample, I'm mapping ports with option '-p'. For more details, see below. | |
PS2: You can add links among containers using --link <container_name>:<alias> option. | |
# Start a bash session at a running container | |
docker exec -it <nome_container> bash |
# require 'pry'; binding.pry | |
# Rails Project Template | |
# Run with: | |
# rails new MyApp -T -m http://............. | |
# John Meehan 2015 | |
# Set the ruby version to that of the RVM | |
insert_into_file('Gemfile', "ruby '#{RUBY_VERSION}'\n", :before => /^ *gem 'rails'/, :force => false) | |
# Set the Gemset name based on the Rails app name | |
insert_into_file('Gemfile', "#ruby-gemset=#{@app_name}\n", :before => /^ *gem 'rails'/, :force => false) |
Magic words:
psql -U postgres
Some interesting flags (to see all, use -h
or --help
depending on your psql version):
-E
: will describe the underlaying queries of the \
commands (cool for learning!)-l
: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)# video.rb | |
class Video < ActiveRecord::Base | |
has_many :categorizations | |
has_many :categories, through: :categorizations | |
end | |
# category.rb | |
class Category < ActiveRecord::Base | |
has_many :categorizations | |
has_many :videos, through: :categorizations |
Originally published in June 2008
When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.
To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.
Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.
#Model | |
@user.should have(1).error_on(:username) # Checks whether there is an error in username | |
@user.errors[:username].should include("can't be blank") # check for the error message | |
#Rendering | |
response.should render_template(:index) | |
#Redirecting | |
response.should redirect_to(movies_path) |