ruby

RSpec double/mock print method from call

谁说我不能喝 提交于 2021-01-29 06:43:38
问题 My method prints in the console a list of viewed TV Shows. I want to test call method which trigger private print_result method: def initialize(parser) @parser = parser @views_hash = parser.page_views end def call puts "\n" puts 'LIST OF MOST POPULAR TV SHOWS' print_results(sort_all) puts "\n\n" end private def print_results(sorted_hash) puts "\n" puts "#{'TV Show'.center(20)} | VIEWS" puts '---------------------+----------' sorted_hash.each do |page, views_no| puts "#{page.ljust(20)} | #

Debugging rails-latex gem on Heroku | ActionView::Template::Error rails-latex failed

核能气质少年 提交于 2021-01-29 06:39:21
问题 Problem: I have a Rails app which generates a pdf via the rails-latex gem. It works just fine on rails s and heroku local . However, trying to use the pdf-generation-link on Heroku throws me We're sorry, but something went wrong. Using heroku logs --tail yields me: Rendered sheets/show.pdf.erb within layouts/application (3.4ms) Running 'pdflatex -halt-on-error -shell-escape -interaction=batchmode input' in /app/tmp/rails-latex/4--3678030941334020140 1 times... Completed 500 Internal Server

Visual Interface to database mysql with Ruby ​​on Rails

北慕城南 提交于 2021-01-29 06:33:22
问题 I just looked at some tutorials Ruby on Rails, and I noticed that they use a lot of code on the command line, but do not feel comfortable with it only when it comes to database, my question is: There are tools you can use it visually ? ps: for my applications I want to use MySQL 回答1: MySQL has a free application with a GUI interface to MySQL: http://dev.mysql.com/downloads/tools/workbench/ If you're willing to pay, the best GUI app I've used is SQLyog: https://www.webyog.com/ 回答2: the best

Ruby use index from loop to lookup JSONB

只愿长相守 提交于 2021-01-29 06:04:54
问题 I have a JSONB column that holds the business hours of a store . As seen below, it doesn't seem to maintain the order in which it was inputted (sunday opens/closes at, monday opens/closes at). I wanted to iterate over the days of the week to produce results by day, and use the day to look up the respective #{day}_opens_at time to display. But I'm unsure how to do this using the loops index. Rather than sunday 09:00:00 - 18:00:00 , it prints out all of the hours: sunday 08:00:00 09:00:00 20:00

Cucumber Order of Execution - Ruby

非 Y 不嫁゛ 提交于 2021-01-29 05:53:59
问题 Is there a way to specify order of execution inside cucumber? For example, rather than running cucumber feature/foo/foo.feature feature/foo/bar.feature to have those execute in that order... I want to run bundle exec cucumber and run in that specified order. I know that features/scenarios should be independent of each other but for the current tests I'm running it's not practical. If there is no "official way" (which seems to be the case) does anyone recommend a good design to implement such

Ruby on Rails 4.1.8 Gem::LoadError for mysql2 gem

寵の児 提交于 2021-01-29 05:51:50
问题 I picked up a 4 year old project written in Ruby 2.1.3 and Rails 4.1.8 . Very few of the gems were versioned but I've managed to get the project running locally by installing mysql2 0.3.20 as suggested in multiple other threads. Doing this required me to (on MacOS) downgrade openssl and mysql with brew install mysql@57 and brew install openssl@10 . I could then install mysql2 with by passing the correct libraries to it: gem install mysql2 -v 0.3.20 -- --with-mysql-config=/usr/local/opt/mysql

Ruby on Rails 4.1.8 Gem::LoadError for mysql2 gem

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-29 05:49:20
问题 I picked up a 4 year old project written in Ruby 2.1.3 and Rails 4.1.8 . Very few of the gems were versioned but I've managed to get the project running locally by installing mysql2 0.3.20 as suggested in multiple other threads. Doing this required me to (on MacOS) downgrade openssl and mysql with brew install mysql@57 and brew install openssl@10 . I could then install mysql2 with by passing the correct libraries to it: gem install mysql2 -v 0.3.20 -- --with-mysql-config=/usr/local/opt/mysql

How would I parse JSON in Ruby to give me specific output

冷暖自知 提交于 2021-01-29 05:28:37
问题 So I'm trying to make in Ruby so that it "Idk how to express myself" parse JSON from this API so the output is: {"infected"=>19334, "deceased"=>429, "recovered"=>14047, "tested"=>515395, "tested24hours"=>8393, "infected24hours"=>351, "deceased24hours"=>11, "sourceUrl"=>"https://covid19.rs/homepage-english/", "lastUpdatedAtApify"=>"2020-07-15T14:00:00.000Z", "readMe"=>"https://apify.com/krakorj/covid-serbia"} and I would like it to only show for example "infected"=>19334, as number 19334 I'm

rbenv: rails: command not found immediately after installing rails 5.2.1

此生再无相见时 提交于 2021-01-29 04:55:38
问题 I have spent the whole day trying to upgrade from Rails 4x to 5.2.1. I was following this guide for the upgrade and I was not able to upgrade successfully. Issue: After "successfully" installing Rails 5 using: ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin17] and did rails -v I get: rbenv: rails: command not found The `rails' command exists in these Ruby versions: 2.2.0 Things that I have tried: gem pristine different gems gem pristine --all this and played around with paths but no

Trouble Installing Ruby 1.9.3 on Mac OSX 10.9.4

梦想的初衷 提交于 2021-01-29 04:43:30
问题 I am fairly amateur when it comes to Terminal and command line therefore I thought I might pose my question here and hopefully one of the many intelligent folks roaming this board would be so kind as to help me understand what I am doing wrong here. I am trying to install 1.9.3 on my Mac for a project on Team Treehouse. I already have 2.0.0 installed. Any help would be great. Thank you. Here is the read out from the log. roberts-imac:~ Jones$ rvm install 1.9.3 Searching for binary rubies,