I'm developing a ruby on rails -v 3.1.3 app that needs to pull a rss feed down. I've successfully installed feedzirra by adding it to my gemfile and running bundle install.
In my controller for the page that will display the rss feed I have
#feed = Feed.new(blog_url_here)
and I have a class named Feed.rb in my models folder that contains this:
def initialize(endpoint)
atom = Feedzirra::Feed.fetch_and_parse endpoint
#atom = atom.is_a?(Feedzirra::Parser::Atom) ? atom : nil
end
When I load the page I get an "uninitialized constant Feed::Feedzirra" error. Anyone know why and how I can fix it?
Maybe it will help someone:
You should restart rails server after bundle install.
Related
I've set up Ahoy in Rails 5.1.5 but it doesn't track visits automatically.
From https://github.com/ankane/ahoy:
Add this line to your application’s Gemfile:
gem 'ahoy_matey'
And run:
bundle install
rails generate ahoy:install
rails db:migrate
Restart your web server, open a page in your browser, and a visit will be created 🎉
I interpret that last line as: An entry will automatically appear in Ahoy::Visit.last when there's a new visit. Unfortunately, there were no rows in this table after a pageview. So I did this in application_controller.rb:
after_action :ahoy_track
private
def ahoy_track
properties = request.path_parameters
properties[:url] = request.url
ahoy.track "Pageload", properties
end
and now I'm getting visitor data. However, when someone comes from Google, Ahoy::Visit.last.search_keyword is nil.
Are these two problems related? What gives? This is deployed to Heroku on a plain vanilla PostgreSQL setup.
I'm crating movie/series focused app and I decided to use this gem: https://github.com/18Months/themoviedb-api#configuration. I added it to my Gemfile, then I used 'bundle install' command, the gem was successfully installed. So far I have done everything by the book. After installation I tried to check if it works properly so I insert this code into one of my controllers' index actions:
def index
#series = Series.all
Tmdb::Api.key("my_api_key")
Tmdb::Movie.detail(550, language: 'it')
end
Unfortunately my app doesn't seem to recognize Tmdb api, and I am getting the error:
uninitialized constant SeriesController::Tmdb
i tried to use asciidoctor gem in my rails app. I added it to my Gemfile and made bundle install.
Now i try to use asciidoctor within a Controller:
def show
#article.text = Asciidoctor.render(#article.text)
end
But i get an error:
uninitialized constant ArticlesController::Asciidoctor
Whats the right way to user asciidoctor-gem with rails?
Please remember to restart your server after changing something outside the Rails auto-reloading path (i.e. app/* and config/routes.rb).
Since the documentation looks exactly like your example
puts Asciidoctor.render '*This* is http://asciidoc.org[AsciiDoc]!'
I'd guess, you simply forgot to restart the server.
I got this error
NameError in WelcomeController#index
uninitialized constant YouTubeIt
Rails.root: C:/Sites/rails_code/youtube
Btw i checked the gem author github, checked sintax of constant, seems everything's alright, so i can't figure it out.
There is a very similar question here:
Uninitialized constant SO
But in his case, there was a typo, i don't have any typo, i even checked the tutorial like 6 times, but there's no apparent error on my side, here's my controller code:
class WelcomeController < ApplicationController
def index
#cliente = ::YouTubeIt::Client.new(:dev_key => "AI39si4Ao5BFsYIkbzko7b9A_iktB2Pc8DAblJJ_JzJx6IL6Mju1dYYkMKY6TByz8MJPXfm4__tCAt9Is6Mvjg2JM55kuJVVqQ")
#videos = #cliente.videos_by(user: "AlbertoMaso2")
end
end
already installed the youtube_it and declared it's presence in the app by adding it to the Gemfile.
I'm stuck on this one and can't get it to work.
Anyone can shed some light upon this?
Thanks in advance!
When you have changed Gemfile, or added a new gem to it, please, make sure that you have updated Gemfile.lock also. To update lock file just run bundle install command.
Then in order to check usability the gem, you could not run whole rails server, but simply rails console with loaded development environment. Do it as follows:
$ rails c
or
$ rails console
Then inside the IRB, you can try your new gem features, in your case as follows:
irb(main):001:0> require 'youtube_it'
=> true
irb(main):002:0> YouTubeIt
=> YouTubeIt
What happens if you change
#cliente = ::YouTubeIt::Client.new...
to
#cliente = YouTubeIt::Client.new...
I have this code in one of my controllers to get access to eventful.
eventful = Eventful::API.new('my_key_here')
However, I get the following error when I refresh my page
uninitialized constant LocationsController::Eventful
I installed the gem version 2.2.1 as directed through http://api.eventful.com/libs and my gemfile contains the line
gem 'eventfulapi', '2.2.1'
I am trying to recreate the example here: http://api.eventful.com/libs/ruby/doc/index.html
I can get it to work in a separate ruby script (e.x. running 'ruby a.rb' through command line) which leads me to thinking it's totally possible. I just can't get it to work in a controller to feed my application.
Try adding require 'eventful/api' at the top of the controller code.