Skip to content

Instantly share code, notes, and snippets.

View ka8725's full-sized avatar
🚀
Ruby on Rails expert with business development mindset | WideFix Founder

Andrei Kaleshka ka8725

🚀
Ruby on Rails expert with business development mindset | WideFix Founder
View GitHub Profile
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:each, js: true) do
irb --simple-prompt
>> a = [1,2,3]
=> [1, 2, 3]
>> a.select {|e| e >= 2}
=> [2, 3]
>> a.detect {|e| e >= 2}
=> 2
require 'active_record'
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'db.sqlite3')
ActiveRecord::Schema.define do
create_table :users, force: true do |t|
end
end
class ActiveRecord::Base
require 'active_record'
require 'minitest/autorun'
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'db.sqlite3')
ActiveRecord::Schema.define do
create_table :users, force: true do |t|
t.references :company, index: true
end
class DeviseCreateUsers < ActiveRecord::Migration
def migrate(direction)
super
# Create a default user
User.create!(email: 'admin@example.com', password: 'password', password_confirmation: 'password') if direction == :up
end
def change
create_table(:users) do |t|
## Database authenticatable
require 'minitest/autorun'
BOOLEAN_MAPPINGS = {
'true' => true,
'false' => false
}
def typecast_hash_values(hash)
hash.each do |k, old_value|
if (new_value = BOOLEAN_MAPPINGS.fetch(old_value, old_value)) != old_value
/usr/local/opt/rbenv/versions/2.1.0/lib/ruby/2.1.0/bigdecimal/util.rb:18: [BUG] Segmentation fault at 0x00000000000000 | ETA: 00:04:13
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin13.0]
-- Crash Report log information --------------------------------------------
See Crash Report log file under the one of following:
* ~/Library/Logs/CrashReporter
* /Library/Logs/CrashReporter
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
for more details.
STEP_DECORATORS_MAPPING = {
step1: Decorator1,
step2: Decorator2
}
step = :step1
STEP_DECORATORS_MAPPING[step].new(...)
x = '123'
x[0, x.length] = 'aa' # x.replace('aa')
RSpec.configure do |config|
config.before do
Category.subclasses.each do |c|
c.instance_variable_set(:@instance, nil)
end
Category.instance_variable_set(:@instances, nil)
end
end