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
# app/models/concerns/multiparameter_attribute_assignment.rb | |
module MultiparameterAttributeAssignment | |
include ActiveModel::ForbiddenAttributesProtection | |
def initialize(params = {}) | |
assign_attributes(params) | |
end | |
def assign_attributes(new_attributes) |
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 list of possible usernames to reserve to avoid | |
# vanity URL collision with resource paths | |
# It is a merged list of the recommendations from this Quora discussion: | |
# http://www.quora.com/How-do-sites-prevent-vanity-URLs-from-colliding-with-future-features | |
# Country TLDs found here: | |
# http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains#Country_code_top-level_domains | |
# Languages found here: |
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 Hash | |
# Extension of the `key?` method to check for existence of multiple keys in | |
# a hash. | |
# | |
# Returns true if all keys matches, false if hash has missing keys. | |
# Returns true if hash has more keys than specified in array. | |
def keys?(array) | |
!array.map { |k| self.key?(k) }.include? false | |
end | |
end |
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
------------ From Rake Task | |
namespace :app do | |
# Checks and ensures task is not run in production. | |
task :ensure_development_environment => :environment do | |
if Rails.env.production? | |
raise "\nI'm sorry, I can't do that.\n(You're asking me to drop your production database.)" | |
end | |
end |
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
# Countries | |
# `alpha2_code` has unique constraint | |
countries_seed_file = File.join(Rails.root, 'db', 'seeds', 'countries.yml') | |
countries = YAML.load_file(countries_seed_file) | |
countries.each do |country| | |
country = country[-1] | |
data = { | |
name: country['name'], | |
continent: country['continent'], |
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
upstream example_name { | |
server unix:///var/www/example_name/shared/sockets/puma.sock; | |
} | |
server { | |
listen 80; | |
server_name example_name.com; | |
root /var/www/example_name/current/public; | |
location / { |
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
namespace :figaro do | |
desc "SCP transfer figaro configuration to the shared folder" | |
task :setup do | |
transfer :up, "config/application.yml", "#{shared_path}/application.yml", :via => :scp | |
end | |
desc "Symlink application.yml to the release path" | |
task :finalize do | |
run "ln -sf #{shared_path}/application.yml #{release_path}/config/application.yml" | |
end |
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
# Knife Configuration File. | |
# | |
# This is a Ruby DSL to set configuration parameters for Knife's | |
# general options. The default location for this file is | |
# ~/.chef/knife.rb. If multiple Chef repositories are used, | |
# per-repository configuration files can be created. A per repository | |
# configuration file must be .chef/knife.rb in the base directory of | |
# the Chef repository. For example, | |
# | |
# ~/Development/chef-repo/.chef/knife.rb |
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
default_run_options[:pty] = true | |
ssh_options[:forward_agent] = true | |
set :user, "<< YOUR WEBFACTION USERNAME >>" | |
set :application, "<< YOUR APP NAME >>" | |
set :repository, "<< YOUR REPOSITORY ADDRESS >>" | |
set :deploy_to, "/home/<< YOUR WEBFACTION USERNAME >>/webapps/<< YOUR WEBAPP DIRECTORY >>" | |
set :default_stage, "production" |
NewerOlder