Skip to content

Instantly share code, notes, and snippets.

View iseitz's full-sized avatar
💭
www.linkedin.com/in/irina-karchebnaya-seitz

iseitz iseitz

💭
www.linkedin.com/in/irina-karchebnaya-seitz
View GitHub Profile
@iseitz
iseitz / regenerate_credentials.md
Created October 4, 2023 06:24 — forked from db0sch/regenerate_credentials.md
How to regenerate the master key for Rails 5.2 credentials

If your master.key has been compromised, you might want to regenerate it.

No key regeneration feature at the moment. We have to do it manually.

  1. Copy content of original credentials rails credentials:show somewhere temporarily.
  2. Remove config/master.key and config/credentials.yml.enc
  3. Run EDITOR=vim rails credentials:edit in the terminal: This command will create a new master.key and credentials.yml.enc if they do not exist.
  4. Paste the original credentials you copied (step 1) in the new credentials file (and save + quit vim)
  5. Add and Commit the file config/credentials.yml.enc

Git Cheat Sheet

Basic commands

git init Creates a new git repository in the directory

git add <file name> Adds a specific file to staging

git add . or git add -A Adds the full directory and its contents to staging

Since it is a second time that I spend 2 hours on the same problem I'll leave the solution here
In case where you run the bundle exec rake db:create for the first time and get the error:
$ "rake aborted!
$ NoMethodError: undefined method 'name' in 'campsite' factory"
The problem is the Deprecation of static attributes in factory_bot 4.11 and up.
In your Gemfile you need to downgrade manually the factory_bot_rails from the latest version to something between 4.8.2 and 4.11
For example it can be: gem 'factory_bot_rails', '~> 4.8.2'
@iseitz
iseitz / Capybara.md
Created February 22, 2019 10:36 — forked from tomas-stefano/Capybara.md
Capybara cheatsheet

Capybara Actions

# Anchor
click_link 'Save'

# Button
click_button 'awesome'

# Both above
@iseitz
iseitz / rspec_rails_cheetsheet.rb
Created February 22, 2019 09:28 — forked from them0nk/rspec_rails_cheetsheet.rb
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@iseitz
iseitz / gist:afb5497b609def91cd1c1793ac4636d8
Created February 21, 2019 06:52
Incompatible library version: nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib
#uninstall nokogiri:
$ gem uninstall nokogiri
#install nokogiri
$ gem install nokogiri
#restart terminal\if needed run gem pristine byebug --version 11.0.0
#solved!
@iseitz
iseitz / nokogiri_libxml_homebrew_lion_installation.sh
Created February 21, 2019 06:49 — forked from vparihar01/nokogiri_libxml_homebrew_lion_installation.sh
How to fix: Nokogiri Incompatible library version: nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib provides version 10.0.0. dlopen bundle.open. Using homebrew on lion to install nokogiri and lixml
FIXME:
WARNING: Nokogiri was built against LibXML version 2.7.3, but has dynamically loaded 2.7.8
or
ERROR -: Incompatible library version: nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib provides version 10.0.0
gem uninstall nokogiri libxml-ruby
brew update
brew uninstall libxml2
$ rvm get stable
# if there is a problem with getting the latest version run:
$ rvm get head
$ rvm reload
$ rvm get stable
# if that does not work try:
$ \curl -sSL https://get.rvm.io | bash -s stable
# On MAC OS High Sierra 10.13.6
# You must recompile Ruby with OpenSSL error:
$ rvm get head
$ rvm pkg remove
$ rvm requirements run
# (I just ran the `rvm requirements` and it installed the missing parts.
# I then reinstalled the newest version of Ruby and Rails, this worked for me.)
$ rvm reinstall 2.6.0

Pry Cheat Sheet

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