Error with Bullet Gem Rails 4 and Uniform Notifier - ruby-on-rails-4

I'm trying to use bullet gem to avoid N+1 queries in my website.
I've used it until some months ago, then it stopped to work. I got this only today.
When I start my localhost I get this error message:
/Users/carcarlo/.rvm/gems/ruby-2.2.4/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `require':/Users/carcarlo/.rvm/gems/ruby-2.2.4/gems/uniform_notifier-1.12.0/lib/uniform_notifier/base.rb:37: syntax error, unexpected <<, expecting keyword_end (SyntaxError)
<<~CODE
^/Users/carcarlo/.rvm/gems/ruby-2.2.4/gems/uniform_notifier- 1.12.0/lib/uniform_notifier/base.rb:38: syntax error, unexpected '<', expecting keyword_end <script #{attributes_string}>/*<![CDATA[*/
^ target of repeat operator is not specified: /*]]>*/
it is clear that is an error in the file base.rb of the gem uniform_notifier, which is a dependency of bullet, but what can I do to get it working on my system?
I tried to force the installation of uniform_notifier to an older version (actual is 1.12.1) but it is locked to 1.12.0
This application is written using ruby 2.2.4 and rails 4.2.5

I was able to fix it by using a lower version of bullet
gem 'bullet', '~> 5.7.6'

Related

"wkhtmltopdf" and "pdfkit" gems -- error "ContentNotFoundError". How to fix it?

I have a Rails app at heroku. I'm using these 2 gems for generating pdf files:
gem "wkhtmltopdf-heroku", "~> 2.12", ">= 2.12.3.0"
gem "pdfkit", "~> 0.8.2"
I sometimes, but not always, I have an error:
ContentNotFoundError
It's probably due to a bug in the C++ library on top on which the gem is built - https://github.com/wkhtmltopdf/wkhtmltopdf/issues/2051
There's even a workaround as they say.
My question -- if that workaround really works, how can it be applied to the gem? How to get rid of the exception in the gem?

Rails 4.2 Time_zone_conversion.rb Error. How do I fix this?

I am totally lost on this one. I'm using ruby 2.2.4 and upgrading an app from rails 4.1.0 to 4.2. The app was working fine. I changed my Gemfile to use:
gem 'rails', '~>4.2'
Then ran my spec tests and the app blew up with this error:
usr/local/rvm/rubies/ruby-2.2.4/bin/ruby -I/path-to-my-app/vendor/bundle/ruby/2.2.0/gems/rspec-core-3.5.0/lib:/path-to-my-app/vendor/bundle/ruby/2.2.0/gems/rspec-support-3.5.0/lib /path-to-my-app/vendor/bundle/ruby/2.2.0/gems/rspec-core-3.5.0/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb
Coverage report generated for RSpec to /path-to-my-app/coverage. 22 / 1206 LOC (1.82%) covered.
/path-to-my-app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/attribute_methods/time_zone_conversion.rb:64:in `create_time_zone_conversion_attribute?': undefined method `type' for "NUMBER(38)":String (NoMethodError)
from /path-to-my-app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/attribute_methods/time_zone_conversion.rb:53:in `block (2 levels) in inherited'
When I try to load the app in a browser I get an error:
undefined method 'type' for "NUMBER(38)":String
I Google'd on this and found one post. It was here in StackOverflow: NoMethodError: Undefined method 'type' for nil:NilClass in Rails, which led me to: https://gist.github.com/alsemyonov/88826/revisions
I tried the fix posted in the github app, but I still get the same error.
A mention of 'time_zone_conversion.rb' in the error and something I read made me think this was :datetime related. I have one method in a couple of models that works on the date field "updated_at". Not sure if this is related or not.
def updated_at_formatted
self.updated_at.strftime("%m/%d/%Y")
end
I'm also using the gem 'american_date'.
Any ideas on what is causing this and how to fix it would be greatly appreciated.
Thanks,
Found it:
Oracle enhanced adapter version 1.6 just supports Rails 4.2 and does not support Rails 4.1 or lower version of Rails.
When using Ruby on Rails version 4.2 then in Gemfile include
gem 'activerecord-oracle_enhanced-adapter', '~> 1.6.0'
A co-worker and I stepped through the stacktrace on the error. He felt that the line:
undefined method 'type' for "NUMBER(38)":String
was somehow tied to a database issue, which for this app is Oracle. Googling on issues on the Rails 4.2 upgrade and the above oracle gem led us to the above answer.

Rubymine throws a **[BUG] Segmentation fault** when trying to run rspec test

I am trying to run my rspec tests from rubymine, but getting this error:
...[BUG] Segmentation fault at 0x00000000000438
ruby 2.1.2p95 (2014-05-08 revision 45877) [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.
-- Control frame information -----------------------------------------------
c:0051 p:-17566078017732 s:0152 e:000151 TOP [FINISH]
c:0050 p:---- s:0150 e:000149 CFUNC :require
c:0049 p:0022 s:0146 e:000145 BLOCK /Users/Sunday/workspace/resilience/vendor/bundle/ruby/2.1.0/gems/nokogiri-1.6.6.2/lib/nokogiri.rb:29
c:0048 p:0149 s:0143 e:000142 TOP /Users/Sunday/workspace/resilience/vendor/bundle/ruby/2.1.0/gems/nokogiri-1.6.6.2/lib/nokogiri.rb:25 [FINISH]
c:0047 p:---- s:0141 e:000140 CFUNC :require
c:0046 p:0064 s:0137 e:000136 TOP /Users/Sunday/workspace/resilience/vendor/bundle/ruby/2.1.0/gems/loofah-2.0.2/lib/loofah.rb:3 [FINISH]
c:0045 p:---- s:0135 e:000134 CFUNC :require...
I have checked on google and followed some stack-overflow answers on how to solve this, but non seems to be working for me.
I have also tried to upgrade the rubymine debugger with the following commands: gem install ruby-debug-base19x --pre and gem install ruby-debug-ide --pre.
the first threw an error:
ruby_debug.c:861:98: error: no member named 'bp' in 'struct rb_control_frame_struct'
if (debug_context->frames[debug_context->stack_size - 1].info.runtime.bp <= thread->cfp->bp),
but the second was successful. Even then I still get the initial error on rubymine when I try to run my tests.
BTW: the tests run well from the terminal, and tests from other projects run well on rubymine. Only this perticular project is not running.
what can I do to make my rubymine run these rspec test from my projects. Thanks for any help.
I finally got it right. I have to go into Rubymine's preferences => Languages and Frameworks => Ruby SDK and Gems to update the version of ruby for the project from 2.1.2 to what is specified in the .ruby-version file for the project, which is 2.1.6.
After doing this, everything worked fine as expected.

Rails + Prawn: undefined method `table' for #<Prawn::Document:0x007fda2d594a98>:

I'm using Rails 4 + prawn_rails + the latest version of prawn (v 1.1.0) and I noticed in the changelog here: https://github.com/prawnpdf/prawn/wiki/CHANGELOG that tables are now separated.
I followed the instructions to require "prawn/tables". I did this by adding a file in my lib directory:
lib/prawn.rb
require "prawn/tables"
I restarted my rails server and I still get the error:
NoMethodError - undefined method `table' for #<Prawn::Document:0x007fda2d594a98>:
How do I fix this?
You should add these lines into your Gemfile.
gem 'prawn', '~> 1.2.1'
gem 'prawn-table', '~> 0.1.0'
The line in the documentation is WRONG. add require 'prawn/table'
to your .pdf.prawn file on the top and it will work.

can't install simple_captcha produces uninitialized constant Sprockets::Helpers

I have included the simple_captcha gem as instructed on their site:
gem 'simple_captcha', :git => 'git://github.com/galetahub/simple-captcha.git'
I have then run bundler to install it.
Finally when I go to run the following command I get an error:
rails generate simple_captcha
.rvm/gems/ruby-1.9.3-p327#eapi4/bundler/gems/simple-captcha-e99cc7e8bf6b/lib/simple_captcha/form_builder.rb:7:in `included': uninitialized constant Sprockets::Helpers (NameError)
I've searched on the web and can't find any other users with this problem.
Any help appreciated
They say in this pull request that the plugin doesn't support rails 4, You can download their branch and try it out.
Looking at the diff it shows your problem
- base.send(:include, Sprockets::Helpers::RailsHelper)
- base.send(:include, Sprockets::Helpers::IsolatedHelper)
+ base.send(:include, Sprockets::Rails::Helper)
https://github.com/galetahub/simple-captcha/pull/39/files
you could this as the previous version of simple_captcha is not supported on rails 3.
Azdaroth forked of simple_captcha
gem 'simple_captcha', :git => 'git://github.com/Azdaroth/simple-captcha.git', :branch => 'rails-4'