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

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.

Related

Error with Bullet Gem Rails 4 and Uniform Notifier

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'

"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.

Disabling the running-twice with Zeus in Rails 4 minitest?

Zeus has a known issue where it runs specs double if you include the default "autorunner" for a testing suite.
It is common to see tests running twice when starting out with Zeus.
If you see your tests/specs running twice, you should try disabling
require 'rspec/autotest' and require 'rspec/autorun' (for RSpec), or
require 'minitest/autorun' (for Minitest). (see #134 for more
information).
https://github.com/burke/zeus#important
However, Rails4 minitest includes "rails/test_help" which is a file in Railties 4.0.0; which includes yet another custom runner. And does other generic of setup and configuration.
For Rails4 with default minitest, there is no simple include to leave out, it seems.
Is there a solution for this?
i was just facing this same problem with Rails4+minitest+zeus.
After i include gem "minitest-rails-shoulda" in my Gemfile, zeus starts to run tests twice.
I just changed the gem orders at Gemfile and it solves!
Gemfile with Zeus running twice:
group :test do
gem "minitest-rails-shoulda"
gem 'minitest'
#...
end
Gemfile CORRECT:
group :test do
gem 'minitest'
gem "minitest-rails-shoulda"
#....
end

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'