Gem NameError when called from other gem - ruby-on-rails

I'm trying to get PartyFoul set up on a Rails project I collaborate on and am running into a weird issue when I run the install generator.
~/.rvm/gems/.../party_foul-1.5.4/lib/generators/party_foul/install_generator.rb:21:in `rescue in create_initializer_file': uninitialized constant PartyFoul::InstallGenerator::Octokit (NameError)
from ~/.rvm/gems/.../gems/party_foul-1.5.4/lib/generators/party_foul/install_generator.rb:17:in `create_initializer_file'
The script is having trouble finding the Octokit gem so if I put require 'octokit' at the top of install_generator.rb, everything is happy. The weird part is that I can't replicate this issue on a clean Rails 4 or Rails 3.2 project that simply has PartyFoul installed, so it must be specific to this project, and while I can get the configuration file set up manually, I'd like to figure out what root cause of this problem is.
Any help would be much appreciated, thanks!

I just figured it out, the PartyFoul gem was in the :production group so I'm assuming that Rails was somehow not loading it properly. I replicated the NameError in the clean Rails project after moving the gem to :production, so that seems to be the difference. I'm not sure what the root cause is, any enlightenment would still be appreciated :-).

Related

What do I need to do to get the blog to work in rails 4.2?

I have just installed rails 4.2 . I have found this tutorial for making a quick blog: https://www.reinteractive.net/posts/32-ruby-on-rails-3-2-blog-in-15-minutes-step-by-step . However, it uses rails 3.2 . I have done everything that it says up to rake db:migrate and yet, when I run the server, I just get an error page. What has changed since 3.2? what do I now have to do to do the same thing?
error:
'ExecJS::ProgramError in Posts#index'
TypeError: Object doesn't support this property or method
(in C:/Ruby193/lib/ruby/gems/1.9.1/gems/turbolinks-2.5.3/lib/assets/javascripts/turbolinks.js.coffee)
EDIT:
On a side note, I can't even follow the official ruby on rails tutorial because when I run the server, after changing the root to root 'welcome#index' , I just get a page not found error.
Are there any tutorials for rails 4.2?
I had exactly the same ExecJS::ProgramError on Windows. The only solution that really helped was provided by KeithP here: Rails-4, ExecJS::ProgramError in Pages#welcome, i.e.,
Rollback to gem 'coffee-script-source', '1.8.0'.
There's some info here: ExecJS::RuntimeError in Users#index (RoR)
What I found when I looked into this problem was that in CoffeeScript there's a checkin here that I think broke things for Windows (under certain versions of the cscript runtime): https://github.com/jashkenas/coffeescript/blob/28c07d30cbd2add7ee762c7d532b2c9c972e441a/lib/coffee-script/parser.js
On line 563 it's doing an Object create(lexer) which fails with the error ActionView::Template::Error (TypeError: Object doesn't support this property or method.
Rolling back to CoffeeScript 1.8.0 (before this change) works around this problem. As others have stated in this answer and elsewhere, using a different runtime will workaround this problem too.
To roll back to CoffeeScript 1.8.0 add this to your gemfile:
gem 'coffee-script-source', '1.8.0'
And run these commands:
gem update 'coffee-script-source'
bundle update 'coffee-script-source'
Restart your server and it should be working.
This should solve your problem:
Add gem 'therubyracer', '~> 0.12.1' into your gemfile (or uncomment it - should be already there...)
Then run bundle install
Hope this helps.

Rails 4 and gem (will_paginate) not deploying correctly

I am working with Rails 4 and I am using this library for my pagination, but I have a problem when I deploy to production, I see this error:
/home/deployer/apps/app/shared/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc1/lib/active_support/dependencies.rb:228:in
require'/home/deployer/apps/app/shared/bundle/ruby/1.9.1/gems/activesupport-4.0.0.rc1/lib/active_support/dependencies.rb:228:inrequire':
No such file to load -- will_paginate/array (LoadError)
In development this library is working but in production I have this error, I was searching for this error on Google but I can't find a solution.
Do you have any idea what may be wrong? Let me know when you find out please.
Thanks for you help.
First things first, check that the will_paginate gem is enabled for production in your Gemfile. It may be under the :development group only.

spree_i18n integration

I'm trying to get the spree_i18n gem working, but am not quite getting it.
I've added this to the Gemfile:
gem 'spree_i18n', :git => 'git://github.com/spree/spree_i18n.git'
I'm using RVM, so bundle installed it to:
~/.rvm/gems/ruby-1.9.3-p125#spree/bundler/gems/spree_i18n-e5e3e189c843
instead of the usual location at:
~/.rvm/gems/ruby-1.9.3-p125#spree/gems/
so I'm not sure if RVM is doing something weird.
But running any of the rake spree_i18n:xxx commands results in the following error:
'Don't know how to build task 'spree_i18n:new'
I'm guessing it's because the gem isn't getting picked up by rake and the app. I was thinking that the app should have picked up on the .yml translation files from the gem folder so I would not need to copy them over to the main app folder.
As a quick fix, I copied over the .yml files from the gem folder to the app config/locales folder. It works but definitely feels like a hack.
Can someone please point me in the right direction to integrate this gem correctly?
I've also posted the question here, in case, there's additional information that might help to solve this.
https://groups.google.com/forum/?hl=en&fromgroups#!topic/spree-user/6ycWGfm6eTk
Thank you for your time!
see related closed issue on github
https://github.com/spree/spree_i18n/issues/171

SslRequirement: uninitialized constant ApplicationController::SslRequirement

I'm trying to add ssl to my rails 3.0.7 app using the ssl requirement gem, but when I type
include SslRequirement
into my Application controller, the app fails and I get the following error:
uninitialized constant ApplicationController::SslRequirement
Anybody seen this before?
As my comments on the question indicate, you're using gem 'sslrequirement' in your Gemfile, which is pulling down a fork of a fork of a fork of the original, none of which (the ancestors) are the (according to the original) official repository.
To fix this, you can use the following line in your Gemfile instead (note the underscore):
gem 'ssl_requirement'
Which will pull down the appropriate Gem from https://rubygems.org/gems/ssl_requirement.

Mimetype-fu isn't working

I feel like this should be an easy answer but I'm totally stumped.
I've added mimetype_fu to my gemfile and it installed it when I ran bundle install. When I try to use File.mime_type? in my application I get an error:
NoMethodError: undefined method `mime_type?' for File:Class
In the rails console when I run
gem 'mimetype-fu'
it returns true
I'm on windows, if that matters
Any ideas?
If you are using Bundler, you can also just add require to the gem line like this.
gem 'mimetype-fu', :require => 'mimetype_fu'
You may need to manually require it inside your rails app. You can do this by adding an file to config/initializers/ if you want it to be available globally.
EDIT | Also, you did restart the rails server, right? ;)

Resources