Command Line
pry -r ./config/app_init_file.rb- load your app into a pry session (look at the file loaded by config.ru)pry -r ./config/environment.rb- load your rails into a pry session
Debugger
| #!/usr/bin/env bash | |
| # run this script from your home folder | |
| # sudo bash | |
| curl -O http://downloads.mongodb.org/linux/mongodb-linux-x86_64-2.6.12.tgz | |
| tar -zxvf mongodb-linux-x86_64-2.6.12.tgz | |
| cp mongodb-linux-x86_64-2.6.12/bin/* /usr/local/bin | |
| groupadd mongodb | |
| useradd --system --no-create-home -g mongodb mongodb |
| # frozen_string_literal: true | |
| require 'rails_helper' | |
| RSpec.configure do |config| | |
| config.use_transactional_fixtures = false | |
| # DatabaseCleaner settings | |
| config.before(:suite) do | |
| DatabaseCleaner.clean_with(:truncation) |
| #!/bin/bash | |
| main() { | |
| if [[ $(has_lvh_me) == 1 ]]; then | |
| echo 'lvh.me is already specified in your hosts file' | |
| else | |
| add_lvh_me | |
| echo 'lvh.me was added to your hosts file!' | |
| fi | |
| flush_dns_cache |
| =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') |
Command Line
pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)pry -r ./config/environment.rb - load your rails into a pry sessionDebugger
| def is_vowel_elsif(letter) | |
| if letter == "a" | |
| true | |
| elsif letter == "e" | |
| true | |
| elsif letter == "i" | |
| true | |
| elsif letter == "o" | |
| true | |
| elsif letter == "u" |
| hash = { 'foo' => 'bar' } | |
| # Version 1 | |
| hash = Hash[hash.map { |k, v| [k.to_sym, v] }] | |
| # Version 2 | |
| hash = hash.reduce({}) do |memo, (k, v)| | |
| memo.tap { |m| m[k.to_sym] = v } | |
| end |
| class ApplicationController < ActionController::Base | |
| ... | |
| #Problem: | |
| #In rails 3.0.1+ it is no longer possible to do this anymore; | |
| # rescue_from ActionController::RoutingError, :with => :render_not_found | |
| # | |
| #The ActionController::RoutingError thrown is not caught by rescue_from. | |
| #The alternative is to to set a catch-all route to catch all unmatched routes and send them to a method which renders an error | |
| #As in http://techoctave.com/c7/posts/36-rails-3-0-rescue-from-routing-error-solution |
| <form action="<%= @pay_desc['mrh_url'] %>" method="post"> | |
| <input type=hidden name=MrchLogin value="<%= @pay_desc['mrh_login'] %>"> | |
| <input type=hidden name=OutSum value="<%= @pay_desc['out_summ'] %>"> | |
| <input type=hidden name=InvId value="<%= @pay_desc['inv_id'] %>"> | |
| <input type=hidden name=Desc value="<%= @pay_desc['inv_desc'] %>"> | |
| <input type=hidden name=SignatureValue value="<%= @pay_desc['crc'] %>"> | |
| <input type=hidden name=Shp_item value="<%= @pay_desc['shp_item'] %>"> | |
| <input type=hidden name=IncCurrLabel value="<%= @pay_desc['in_curr'] %>"> | |
| <input type=hidden name=Culture value="<%= @pay_desc['culture'] %>"> | |
| <input type=submit value='Оплатить'> |
| # config/routes.rb | |
| YandexKassaIntegration::Application.routes.draw do | |
| # ... | |
| scope '/yandex_kassa' do | |
| controller 'yandex_kassa', constraints: { subdomain: 'ssl' } do | |
| post :check | |
| post :aviso | |
| get :success | |
| get :fail |