This is an opinionated handbook on how I migrated all my Rails apps off the cloud and into VPS.
This is how I manage real production loads for my Rails apps. It assumes:
- Rails 7+
- Ruby 3+
- PostgreSQL
- Ubuntu Server 24.04
- Capistrano, Puma, Nginx
This is an opinionated handbook on how I migrated all my Rails apps off the cloud and into VPS.
This is how I manage real production loads for my Rails apps. It assumes:
## Context + metadata | |
shared_context 'Logged as a user', role: true do | |
let(:user) { |example| create :user, example.metadata[:role] } | |
before { login_as user } | |
end | |
scenario "Login as a client", role: :client | |
scenario "Login as a customer", role: :customer | |
scenario "Login as an admin", role: :admin |
destination (10.0.0.3) <- |NAT| <- source (192.168.1.105)
SSH from the destination to the source (with public ip)
ssh -f -N -R 19999:localhost:22 [email protected]
SSH from source to destination through above tunel
# Rake task to help migrating a rails 3 app to rails 4 strong_parameters. | |
# The task generates source code for helper methods for each model class | |
# to 'permit' the attributes. | |
# The generated methods are intended as starting point to copy&paste in the | |
# controller and than edit the permitted attributs. | |
# Some common names of non-editable attributes are already filtered, | |
# like 'id', 'password' or 'created_at'. | |
# The output is written to stdout so you can pipe it into a file | |
# | |
# Dependencies: |
describe PostPolicy do | |
let(:scope) { Post.where(:published => true } | |
subject(:policy_scope) { PostPolicy::Scope.new(user, scope).resolve } | |
permissions ".scope" do | |
context "for an ordinary user" | |
let(:user) { User.new(:admin => false) } | |
it "hides unpublished post" do | |
post = Post.create(:published => false) |
require 'will_paginate/array' | |
describe "recurrences/index" do | |
let(:recurrences) do [ | |
FactoryGirl.build(:recurrence, scheduled_to: "2012-07-05"), | |
FactoryGirl.build(:recurrence, scheduled_to: "2012-07-12"), | |
FactoryGirl.build(:recurrence, scheduled_to: "2012-07-19") | |
] | |
end | |
require 'will_paginate/array' | |
describe "recurrences/index" do | |
let(:recurrences) do [ | |
FactoryGirl.build(:recurrence, scheduled_to: "2012-07-05"), | |
FactoryGirl.build(:recurrence, scheduled_to: "2012-07-12"), | |
FactoryGirl.build(:recurrence, scheduled_to: "2012-07-19") | |
] | |
end |