I get the following error when trying to use the AudioInfo class (that comes with the ruby-audioinfo gem):
uninitialized constant PlaylistsController::AudioInfo
I have bundled the gem. Have restarted my server as well. Mp3Info seems to be working fine as I am using ruby-mp3info gem as well. Using rails 4 and latest gem version: https://github.com/moumar/ruby-audioinfo
You need to require the gem for your PlaylistsController class. Try putting this at the top of your file:
require 'audioinfo'
Related
I'm trying to create a Ruby on Rails web app that will sync with google calendar. I tried to use omniauth but it didn't work for me.
I found a rails gem that should do the job for me: gcal4ruby
But for now it isn't working.
I use the code:
#serv = Service.new
#serv.authenticate 'account#gmail.com', 'pass'
and got an error:
uninitialized constant UsersController::Service
In my gemfile using:
gem 'gcal4ruby', '0.5.5'
Gem was installed successfully after bundle install.
By trying to use similar gems I got the same error so I suppose that issue is something else.
I tried to use require "gcal4ruby" in my code and got error:
cannot load such file -- gcal4ruby
I'm using ruby 1.9.3 and rails 4.0.2.
Thanks for help.
Try:
require 'gcal4ruby'
include GCal4Ruby
Which mixes-in the Service class.
Note, that GCal4Ruby uses version 2 of the google calendar api which is deprecated and will not work after November-17th 2014.
Here is a great tutorial on getting a rails app working using omniauth.
I'm trying to install the calendar_helper gem. I included the gem in my Gemfile:
gem 'calendar_helper'
I ran bundle install and loaded fine.
Using calendar_helper (0.2.4)
0.2.4 is the newest version in GitHub, so that looks good. I'm running on Pow so I don't need to restart the server (though I tried that anyway). Adding a call to the method calendar throws an error:
undefined method `calendar'
I feel like something could be wrong with my Rails installation or something. Any ideas?
It doesn't look like version 0.2.4 is up-to-date with what's on github; it's missing the subclass of Rails::Engine necessary to load the helper. The key line on the edge source is here: https://github.com/topfunky/calendar_helper/blob/master/lib/calendar_helper.rb#L231.
You may be able to fix this by installing the gem from edge:
gem 'calendar_helper', :git => 'git://github.com/topfunky/calendar_helper.git'
Edited:
If that still isn't working, you can also try this in your ApplicationHelper:
require 'calendar_helper'
module ApplicationHelper
include CalendarHelper
end
I'm having an issue with using RedCloth in my local application. I keep getting the following error:
uninitialized constant ActionView::CompiledTemplates::RedCloth
This happens because I have the following code:
<%= RedCloth.new("Some text").to_html %>
What I tried to do is put this in the environment.rb file:
require "RedCloth"
However, when I do this, I get a huge error with my Phusion Passenger + Nginx configuration, which I've detailed in the following forum: http://railsforum.com/viewtopic.php?id=42560
Any help would be great. Thanks!
Make sure your Gemfile has a gem 'RedCloth' in it. Regardless of which gems are actually installed in your system, Rails will only use the gems listed in your Gemfile. You do not need the require "RedCloth" statement either.
I had exactly the same error and gem 'RedCloth' line was present in Gemfile. What helped was adding require statement in the beginning of controller file
require 'redcloth'
class StaticController < ApplicationController
...
I've been trying to use HTTParty in my rails code
sudo gem install httparty
From the command line I can now successfully do
httparty "http://twitter.com/statuses/public_timeline.json"
When I try this in my rails app
require 'rubygems'
require 'httparty'
class FooController < ApplicationController
include HTTParty
def bar
blah = HTTParty.get("http://twitter.com/statuses/public_timeline.json")
end
end
I get the error message "no such file to load -- httparty"
I suspect there is something wrong with my environment?
You don't need to do 'include HTTParty' inside the Controller. Just remove that and it should work. I just tested it and it worked for me. If this doesn't work for you, you should add the gem to your environment.
Usually if you use a gem inside your Rails application, you should add the following to environment.rb:
config.gem "httparty"
The gem will be available in the application now and you don't need to add 'require' inside the Controller. Also, you don't need to require RubyGems inside a Controller.
When you use Rails 3, you need to put the following inside the Gemfile:
gem "httparty"
I hope it works for you. :)
The problem is, if you load a new gem, you have to restart the server even if you are in development.
I had this same error. I tried moving the require HTTParty all over, but found, all I needed to do was restart the rails server In the end I did not need to 'require HTTParty' nor 'include' it. It just needed to be loaded into rails.
1)include the httpary in your gemfile
open your gem file then add
gem 'httparty','YOUR VERSION NUMBER'
2) run bundle install in your command prompt of the app file
3) restart the server
Ran into the same problem. Then I switched from Ruby 1.8.7 to Ruby 1.9.2 and all errors varnished into thin air.
(Yes, it first took me quite some hours to come up with the possibility that the Ruby version might be the problem. Configured a secundairy server to avoid possible conflicts with 2 ruby versions, and after way to many hours I got my RoR stack up and running. And the first test with httparty (based on the example on top) worked out of the box! Finally can sleep RESTfully again :-)
I run into the same error whilst reviewing a project from a student, I change the name of the Gem from uppercase to lowercase then run bundle install. I then went ahead to change the format in which they were being imported from
require 'HTTParty' to require 'httparty' and boom it worked
I'm looking to use the latest Twitter gem for a Rails app I'm working on.
However, executing the following line:
oauth = Twitter::OAuth.new(ServiceAPIKeys.twitter['api_key'], ServiceAPIKeys.twitter['secret_key'])
Triggers the following exception:
uninitialized constant Twitter::OAuth
I do have the gem configured in my environment.rb using 'config.gem 'twitter'' and I have the gem unpacked into my vendor/gems directory. I've also tried tossing a 'require 'twitter'' inside the controller where I'm calling it.
Am I missing something obvious or is this an issue with the current gem?
What worked for me (Twitter4r is not installed on my system) is inserting "gem 'twitter'" like in:
require 'rubygems'
gem 'twitter' <<--- INSERT THIS
require 'twitter'
Problem found. There was another included gem, 'Twitter4r' that was using the Twitter namespace and it was taking precedence over the Twitter gem.