Ransack Search Id and Strings Together
I am trying to search using Ransack but having issue when i am trying to search id and string together like:id_or_title_or_user_username_contIt produces the error ActionView::Template::Error...
View Articleusing sequel jdbc in ruby to connect to microsoft sql server 2012 - running...
I am trying to connect to Microsoft sQL Server 2012 database in ruby using the sequel gem.This is what I have require "sequel:require "activerecord-jdbcmssql-adapter"@db =...
View ArticleDevise error undefined method `email'
I have tried tuning my Devise views and have replaced email by username. For sure, I have adjusted initializers/devise.rb by replacing all the occurences of :email by :username. I adjusted screens and...
View ArticleHow to define a method for a block in Ruby?
I'm trying to make this work (it's a simplified example):console do say "Hello" say "Bye"endHere, I want somehow make the say method available only inside the block provided to the console method. How...
View ArticleI am facing issues after updating jekyll to version 4.3.3
I had jekyll working fine before updating my rubygems. After updating jekyll and some rubygems, I encounter exceptions being raised on my cmd.After jekyll updated to v4.3.3, I had issues running even...
View ArticleRuby and money, in a rails app, how to store money values in the db?
I want to make sure I don't have rounding issues when it comes to storing prices for products in a rails app.What mysql datatype should I use, and what does it map to in rails?I want decimal with 10...
View ArticleConvert full-width Japanese text to half-width (zen-kaku to han-kaku)
In PHP it's possible to convert double-width characters to single width with the function mb_convert_kana. They call it "convert zen-kaku to han-kaku".For example, I have a string to convert:dbl =...
View ArticleGrape-Swagger: Route Parameter issues
I am using grape-swagger to show documentation on my Ruby API I'm building using Grape.I am adding descriptions to all of my parameters on my endpoints but I can't seem to find anything about how to...
View ArticleGeocoding API's response was not valid JSON (in response to a basic search)
I am using the Geocoder gem (https://github.com/alexreisner/geocoder) version 1.8. Whenever I run Geocoder.search('Paris') in the Rails console, I get this response:Geocoding API's response was not...
View ArticleInstalling nio4r via brew install throws an error on macOS catalina
I understand that this issue has a ton of answers on stack overflow (and other sites) but none of them seem to work for me. Here is where the issue arises. When I tried to run my server, this error...
View ArticleCan we run Sidekiq for Rails 2.3 application?
In one of the Rails application I'm working, we need to implement background processing. Nowadays, Sidekiq is very popular.But, we are using Rails 2.3.18 and Ruby 1.8.7 and we cannot change it as of...
View ArticleQuery on a time range ignoring the date of timestamps
I'm trying to query a purchases table in my rails database (Postgres) and I want to query on time ranges.For example, I'd like to know how many purchases were made between 2 PM and 3 PM across all...
View ArticleUnexpected results from SQL query with BETWEEN timestamps
I have created a little test app to track down a problem I experienced with Postgres on Heroku: http://snippi.com/s/xd511rfAs you can see in line 49, I want to retrieve all entries created today. This...
View ArticleMiniTest - ReRun only failed tests
Is it possible to let minitest run only the failed tests via rake task?Couldnt find anything in internet about this...With rspec or cucumber it worked.. Is there any possibility here?
View ArticleRails Mongoid has_many query not using foreign_key
I am using mongodb for first time. I have below modelsclass Legacy::User include Mongoid::Document has_many :customers field :username, type: Stringendclass Legacy::Customer include Mongoid::Document...
View ArticleHow to solve gem conflict error? - Ruby/Rails
Trying to run gem install slickgrid-rails it shows:ERROR: While executing gem ... (Gem::DependencyResolutionError) conflicting dependencies actionpack (~> 3.1.0) and actionpack (= 3.0.0) Activated...
View ArticleCan't install Devise
Trying to install Devise and I get the following message "Could not find generator devise:install."leigh@leigh-VirtualBox:~/Projects/dev01$ bundle installUsing rake 10.3.2Using i18n 0.6.11Using json...
View ArticleAssigning to model in controller method does nothing
I want to assign values to my Item model right before saving it in the create method of my ItemsController that handles POST requests. But it seems like nothing happens.# app/models/item.rbclass Item...
View ArticleRuby library function to transform Enumerable to Hash
Consider this extension to Enumerable:module Enumerable def hash_on h = {} each do |e| h[yield(e)] = e end h endendIt is used like so:people = [ {:name=>'fred', :age=>32}, {:name=>'barney',...
View ArticleFibonacci sequence in Ruby (recursion)
I'm trying to implement the following function, but it keeps giving me the stack level too deep (SystemStackError) error.Any ideas what the problem might be ?def fibonacci( n ) [ n ] if ( 0..1...
View Article