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
| max = -1 | |
| vowels_hash.each do |vowel, frequency| | |
| if frequency > max | |
| max = frequency | |
| end | |
| end |
| animal = "cat" | |
| class << animal | |
| def speak | |
| puts "miow" | |
| end | |
| end | |
| animal.speak | |
| #self is assigned to the object and then the method is found for this class of the object via Singleton (unique methods table). One to the right, one up |
| class PlayingCard | |
| attr_accessor :rank, :suite | |
| def initialize (rank, suite) | |
| @rank = rank | |
| @suite = suite | |
| end | |
| def face_card? | |
| ['K', 'Q', 'J'].include?(@rank) | |
| end |
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
| # 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 |
| $ 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 |
| 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 |
| #uninstall nokogiri: | |
| $ gem uninstall nokogiri | |
| #install nokogiri | |
| $ gem install nokogiri | |
| #restart terminal\if needed run gem pristine byebug --version 11.0.0 | |
| #solved! |
| #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) |