It is easy to add wrappers for input components in simple_form, but it takes some time to modify rendering of buttons ("f.button").
We want to have this in our form:
= f.button :submit_cancel, 'Save'
require "net/imap" | |
imap = Net::IMAP.new("imap.domain.sk") | |
imap.login("[email protected]", "HESLO") | |
imap.select("inbox") | |
# search for emails that you want to delete | |
bad_messages = imap.search(["FROM", "[email protected]"]) | |
puts "#{bad_messages.count} messages will be deleted" |
upstream backend { | |
server 127.0.0.1:3000; | |
} | |
server { | |
listen 80; | |
access_log /var/log/nginx/yoursite.access.log; | |
error_log /var/log/nginx/yoursite.error.log; |
module EnumI18nHelper | |
def enum_options_for_select(class_name, enum) | |
class_name.send(enum.to_s.pluralize).map do |key, _| | |
[enum_i18n(class_name, enum, key), key] | |
end | |
end | |
def enum_t(model, enum) | |
enum_i18n(model.class, enum, model.send(enum)) | |
end |
=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') |
module SpecificNumeric | |
refine Numeric do | |
PRESET_ITERATIONS_COUNT = 5 | |
def look_and_say | |
_deep_look_and_say(Array.new(1, self)) | |
end | |
private |
# This is a skeleton for testing models including examples of validations, callbacks, | |
# scopes, instance & class methods, associations, and more. | |
# Pick and choose what you want, as all models don't NEED to be tested at this depth. | |
# | |
# I'm always eager to hear new tips & suggestions as I'm still new to testing, | |
# so if you have any, please share! | |
# | |
# @kyletcarlson | |
# | |
# This skeleton also assumes you're using the following gems: |
Предыдущий: https://2ch.hk/pr/res/560026.html
RUBY_SHAPKA VERSION = 1.0.6
FAQ:
1. C чего мне начать, чтобы стать рубистом? Отличным началом будет Programming Ruby (The Pragmatic Programmers Guide), читать Eloquent Ruby и The Well Grounded Rubyist после прочтения первой толку особо не даст, одни и теже вещи, дальше читаем Ruby Way, затем познаем метапрограммирование с Metaprogramming Ruby. А дальше открываем Ruby cookbook 2015 года, Пишем свой код во время чтения.
Следующий уровень, продвинутые книги по руби:
#openssl | |
require 'openssl' | |
require 'base64' | |
require "digest" | |
include OpenSSL | |
def aes256_encrypt(key, data) | |
key = Digest::SHA256.digest(key) if(key.kind_of?(String) && 32 != key.bytesize) | |
aes = OpenSSL::Cipher.new('AES-256-CBC') | |
aes.encrypt |
namespace :grape do | |
desc 'Print compiled grape routes' | |
task :routes => :environment do | |
API.routes.each do |route| | |
puts route | |
end | |
end | |
end |