I'm trying to use Feedzirra in my Rails 3.2 app to do simple feed parsing. I found this online: http://asciicasts.com/episodes/168-feed-parsing. I followed the instructions there to install the gem, but I believe this instructions are somewhat out of date, since it refers to placing a config.gem line in my config/environment.rb file, which cannot accommodate such calls. I am getting an uninitialized constant ApplicationController::Feedzirra error and I'm not sure why.
I put this code in my application controller:
before_filter :load_blog_feed
def load_blog_feed
feed = Feedzirra::Feed.fetch_and_parse(feed_url)
#blog_posts = feed.entries[0...3]
end
I placed this line in config/application.rb:
config.gem "pauldix-feedzirra", :lib => "feedzirra", :source => "http://gems.github.com"
Lastly, I placed this code in a view:
<div id="blog_feed">
<% #blog_posts.each do |post| %>
<p>
<span class="post_title"><%= link_to "#{post.title} >>", post.url %></span><br>
by <span class="post_author"><%= post.author %></span> on <span class="post_date"><%= post.published %></span>
</p>
<% end %>
</div>
For Rails 3.2 , to be more precise, add the following line to config/application.rb file :
config.gem "feedzirra", :lib => "feedzirra", :source => "http://gems.github.com"
and following line to Gemfile :
gem 'feedzirra'
Then run :
bundle install
Then you can use feedzirra in your application smoothly.
Ok, I found the answer... just include gem 'feedzirra' in your Gemfile and run bundle install. gem 'pauldix-feedzirra' doesn't seem to work, though.
use Bundler!
place
----- EDITED
gem 'feedzirra'
into Gemfile, and run bundle install
Related
I've found a lot of links regarding this problem googling. but nevertheless I still get this error after implementing those fixes.
so my gemfile
gem 'will_paginate', '~> 2.3.16'
environment file
config.gem 'will_paginate', :version => '~> 2.3.16'
Controller
def index
#events = Event.paginate({:page => params[:page], :per_page => 10})
end
View:
<% #events.each do |item| %>
...
<% end %>
...
<%= will_paginate #events %>
I'm using rvm, console commands
rvm 1.8.7 do bundle install
...
rvm use 1.8.7 do bundle exec rake gems:install
Could anyone help me with this problem?
try this one
def index
#events = Event.all.paginate({:page => params[:page], :per_page => 10})
end
Note: If u get same error still, then just comment out logic of pagination and insert some records in your database table(model) and then use pagination.
You cannot call paginate on a model. It can be called on collections like hashes, array, ActiveRecord.
It may be just a case of restarting the server after you have installed the gem.
The team behind Devise announced via blogpost
http://blog.plataformatec.com.br/2013/05/devise-and-rails-4/ that it was releasing a version that is compatible with Rails 4, calling it '3.0 rc'. In the same blog post, it also said it's releasing Devise 2.2.4.
I'm trying to build a Rails 4 app. when I did gem install Devise, it installed 2.2.4, not the version compatible with Rails 4.
Fetching: devise-2.2.4.gem (100%)
Which I assume from the comments in the blogpost about strong parameters is not going to be compatible with Rails 4.
I looked at Devise's github page but it's not obvious to me how to install the version compatible with Rails 4. Can you assist?
https://github.com/plataformatec/devise
Note, I tried
gem install devise --version 3.0.0.rc1
but it said
ERROR: Could not find a valid gem 'devise' (= 3.0.0.rc1) in any repository
ERROR: Possible alternatives: devise
Devise is now compatible with Rails 4 out of the box as of the time of this answer.
Our end goal is to have users be able to register, log in and log out of the website. We'll also create a small partial view letting us know if we're logged in or out.
Install the Devise gem.
Open up your Gemfile and install the Devise gem.
gem 'devise'
Then in your terminal run the bundle install command to install the gem.
$ bundle install
Run some Devise generators to set up the initial configurations.
Run this command from your terminal:
rails generate devise:install
This generator installs the initializer that configures all of Devise's available settings.
Generate your User model.
Next we need to generate our User model. I'm going to name it User but you can name it whatever you like, just replace User with Whatever.
rails generate devise User
rake db:migrate
Configure your default URL option for Development.rb
Inside of config/environments/development.rb, set the Action Mailer's default URL to localhost:
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
Make sure you have a root route declared in Routes.rb
You need to make sure that routes.rb has a default root route - if you don't have one, set it!
root to: 'home#index'
Create a partial view to see if we're logged in or not.
Inside of your views/layouts folder create a file named _user_widget.html.erb and copy this code in:
<% if user_signed_in? %>
<p>Welcome <%= current_user.email %></p>
<%= link_to 'Logged In [click to logout]', destroy_user_session_path, :method => :delete %>
<% else %>
<p>You are not signed in.</p>
<%= link_to 'Login', new_user_session_path %>
<% end %>
And invoke it within your layout (views/layouts/application.html.erb):
<!DOCTYPE html>
<html>
<head>
<title>FacebookAuthTest</title>
<%= stylesheet_link_tag "application", media: "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
<%= yield %>
<%= render 'layouts/user_widget' %>
</body>
</html>
Make sure you stop and restart the server otherwise you will find all sorts of nasty bugs! It's always best to restart your local
server when you update your gemfile or change anything in the
environment configuration file.
With all this in place, you should be able to sign up, log in and log out from your very own Rails website.
If you have any questions feel free to leave a comment below and I'll try to help.
UPDATE SEPT 17th, 2013: The master branch is now compatible with Rails 4. No need to search for another version.
Looking at the github repo, it looks like you want version 3.0.0.rc (no 1). So you'll want
gem install devise --version "3.0.0.rc"
or, in your gemfile:
gem 'devise', '3.0.0.rc'
This installed it
gem install devise --pre
or
devise-3.0.0.rc.gem
At this point this version of the gem is what you would want to use
gem 'devise', '3.0.0'
gem 'devise', github: 'plataformatec/devise', branch: 'rails4'
Now that the 3.0 version is stable, you can just do:
gem install devise
or in your Gemfile:
gem 'devise'
So I just tried to install ckeditor in rails, however it doesn't look like its working.
Here is what I did
added these lines to my gemfile
gem "ckeditor", "~> 3.6.0"
gem "paperclip"
Then bundled installed and ran
rails generate ckeditor:install
rails generate ckeditor:models --orm=active_record
Added this file tom config/application.rb
config.autoload_paths += %W(#{config.root}/app/models/ckeditor)
And then I tried out this code:
<%= javascript_include_tag :ckeditor %>
cktext_area_tag("test_area", "Ckeditor is the best")
cktext_area_tag("content", "Ckeditor", :input_html => {:cols => 10, :rows => 20}, :toolbar => 'Easy')
However, all I am getting is two textareas that do not have any editing ability. They look like normal textareas and all I can do is erase and add text.
What am I doing wrong?
This works like a charm, just tested it on rails 3.1.rc6. Also be cautious of the gem you are using. As of the moment of this post, the oficial gem was not working and was waiting for a pull request, so be sure to use fxposter's version of the gem in your gemfile.
https://github.com/fxposter/rails_3_1_with_ckeditor_and_carrierwave
I had the same setup as you and the same issue. With jalagrange's example app as a comparison to mine, I eventually found the issue to be in development.rb. I had to remove this line:
config.assets.debug = true
It worked for me with after that.
I had a similar issue when I was setting it up a while ago. I gave up on the gem eventually. The problem was getting ckeditor to behave in the asset pipeline, but I had mixed results depending on the browser (of course IE was the problem). Here is what worked for me:
Download ckeditor package from their site and drop in to public/ckeditor.
Then, directly include the javascript files.
<%= javascript_include_tag "/ckeditor/ckeditor" %>
<%= javascript_include_tag "/ckeditor/adapters/jquery" %>
Not exactly elegant, but it worked and haven't had to touch it since.
STEP 1: Add gem 'paperclip' and gem "ckeditor" in your gemfile.
STEP 2: Bundle Install.
STEP 3: rails generate ckeditor:install --orm=active_record --backend=paperclip
STEP 4: Place config.autoload_paths += %W(#{config.root}/app/models/ckeditor) in application.rb
STEP 5: Place mount Ckeditor::Engine => "/ckeditor" if not present already and run db:migrate
STEP 6: Open application.html.erb and place this <%= javascript_include_tag 'ckeditor/ckeditor.js' %> in header.
STEP 7: Place this in footer(above the body tag) in application.html.erb
<script type="text/javascript">$(document).ready(function() {
if ($('textarea').length > 0) {
var data = $('textarea');
$.each(data, function(i) {
CKEDITOR.replace(data[i].id);
});
}
});</script>
STEP 8: Restart the WEBrick SERVER.
That's it.
I have just installed a base installation of rails and have edited the main page to view some basic html and a link to create a new blog post via ruby in the corresponding 'erb' file. I am trying to add some additional ruby commands on this same page via <%= %> tags.
<h1>Hello, Rails!</h1> <%= link_to "My Blog", posts_path %>
<p>
<%= require 'rubygems' %>
<%= require 'simplegeo' %>
<%= SimpleGeo::Client.set_credentials('token', 'secret') %>
<%= a = SimpleGeo::Client.get_context(coordinates,coordinates); a %>
</p>
When I load this page , I get the following error: no such file to load -- simplegeo
Can someone point me in the right direction? Many thanks!
In Rails 3, you need to add this gem to your "Gemfile" .. follow this: http://gembundler.com/rails3.html
Remove this completely.. Never do this in your views
<%= require 'rubygems' %>
<%= require 'simplegeo' %>
Once you restart your rails server, if you added "simplegeo" to your gemfile, it'll be auto-required.
Move this to your controller to start
SimpleGeo::Client.set_credentials('token', 'secret')
#simple_geo_client = SimpleGeo::Client.get_context(coordinates,coordinates)
Then in your view, you can access any variable that starts with #
To get started in Rails, check out http://railsforzombies.org/
In rails 3.x, you use Bundler to specify gems. No need to require, especially in views.
Correct way is:
Open Gemfile
Set/List required gems inside using format:
source :rubygems
gem "simplegeo"
gem "some_other_gem"
Run bundle install (or just bundle) command in console.
now restart your server and gems are auto required.
Check out Rails guide on how to start.
Most probably you did not install Simplegeo gem properly, or did not attach it correctly in you IDE.
I am following the railstutorial.org tutorial. While I am able to see the gravatar on the webpage, my rspec test is failing.
Here is the user_controller_spec.rb test:
describe "GET 'show'" do
before(:each) do
#user = Factory(:user)
end
it "should be successful" do
get :show, :id => #user
response.should be_success
end
end
Here is the relevant show.html.erb file:
<table class="profile" summary="Profile information">
<tr>
<td class="main">
<h1>
<%= gravatar_image_tag(#user.email) %>
<%= #user.name %>
</h1>
</td>
<td class="sidebar round">
<strong>Name</strong> <%= #user.name %><br />
<strong>URL</strong> <%= link_to user_path(#user), #user %>
</td>
</tr>
</table>
I get an error stating "undefined method 'gravatar_image_tag'. I already installed the corresponding gem by executing "gem install gravatar_image_tag", added it to my gemfile, and also executed "bundle install". It is listed as installed when I execute "gem list"
I have been trying to debug this for several hours now. Any help would be appreciated. Thanks in advance. BTW, I'm running 32-bit Windows 7 with GIT Bash, RubyInstaller-1.9.2-p0.
Error message:
Following the same tutorial, I had the same undefined method 'gravatar_image_tag' error, but a different solution from the accepted one above (my gem was in the correct place in the Gemfile, so that wasn't the problem).
Just had to restart the server (Ctrl C then rails server), and then everything was fixed.
Is the gravatar_image_tag gem global to all environments in your gemfile? If you have it in a group :development, :production block, or something similar, it wouldn't be available in test.
And I haven't tried it, but your line:
get :show, :id => #user
seems like it needs to be:
get :show, :id => #user.id
I'm the author of the gem. Can you open an issue on the github page http://github.com/mdeering/gravatar_image_tag/issues with the version of rails and a gem list for me. I will see if I can resolve the issue for you and post an answer back here.
I have some pre-release versions of the gem that I could push out to gemcutter that might resolve the issue already.
Cheers,
Mike D.
If you use Spork as DRB server try to restart it, that helped me! (i'm also following Hartls PDF).
I had the same issue, a simple restart fixed it.
The gravatar gem file has been updated since the release of Michael Hartl's PDF.
gem 'gravatar_image_tag'
Include that in your Gemfile and then restart your rails server using
rails s
That worked for me.