install phantomjs
brew install phantomjs
Gemfile:
group :test do
gem 'poltergeist'
gem 'database_cleaner'
install phantomjs
brew install phantomjs
Gemfile:
group :test do
gem 'poltergeist'
gem 'database_cleaner'
# This works with steak 0.3.x and rspec 1.x | |
# For steak --pre and rspec 2 see this fork: http://gist.github.com/448487 | |
# Put this code in acceptance_helper.rb or better in a new file spec/acceptance/support/javascript.rb | |
Spec::Runner.configure do |config| | |
config.before(:each) do | |
Capybara.current_driver = :selenium if options[:js] | |
end |
# Copyright 2018 SwiftComply.com | |
commands: | |
01_node_install: | |
test: "[ `node --version` != 'v8.10.0' ]" | |
command: "curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -" | |
02_yarn_repo: | |
test: "[ ! -f /etc/yum.repos.d/yarn.repo ]" | |
command: "curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo" | |
03_yarn_install: | |
test: "[ ! -x /usr/bin/yarn ]" |
require 'mechanize' | |
# Create a new instance of Mechanize and grab our page | |
agent = Mechanize.new | |
page = agent.get('http://robdodson.me/blog/archives/') | |
# Find all the links on the page that are contained within | |
# h1 tags. | |
post_links = page.links.find_all { |l| l.attributes.parent.name == 'h1' } |
module Taggable | |
extend ActiveSupport::Concern | |
included do | |
attr_accessible :tags | |
after_save :set_tags | |
after_destroy :unset_tags | |
end |
PASSWORD_VALIDATOR = /( # Start of group | |
(?: # Start of nonmatching group, 4 possible solutions | |
(?=.*[a-z]) # Must contain one lowercase character | |
(?=.*[A-Z]) # Must contain one uppercase character | |
(?=.*\W) # Must contain one non-word character or symbol | |
| # or... | |
(?=.*\d) # Must contain one digit from 0-9 | |
(?=.*[A-Z]) # Must contain one uppercase character | |
(?=.*\W) # Must contain one non-word character or symbol | |
| # or... |
gem 'kaminari' | |
gem 'ransack' |
Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.
Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.
As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.
Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.
# lib/custom_logger.rb | |
class CustomLogger < Logger | |
def format_message(severity, timestamp, progname, msg) | |
"#{timestamp.to_formatted_s(:db)} #{severity} #{msg}\n" | |
end | |
end | |
logfile = File.open("#{Rails.root}/log/custom.log", 'a') # create log file | |
logfile.sync = true # automatically flushes data to file | |
CUSTOM_LOGGER = CustomLogger.new(logfile) # constant accessible anywhere |
<% flash.each do |type, message| %> | |
<div class="alert <%= bootstrap_class_for(type) %> fade in"> | |
<button class="close" data-dismiss="alert">×</button> | |
<%= message %> | |
</div> | |
<% end %> |