Devise issue Ruby on rails - ruby-on-rails

I'm trying to get Devise working. I'm following this tutorial which tells me to do "rails generate devise User" but when I do that command, it gives me an error saying
"NameError: uninitialized constant User from /var/lib/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2503:in `const_missing'"
What am I doing wrong? I'm using Rails 3.0.9, Ruby 1.8.7 and Ubuntu 11.04
Thanks a bunch in advance,
Michael.

Do you have gem devise in your Gemfile? Then, run bundle install. You can also try putting require 'devise' in your config/application.rb file (but you shouldn't have to do this).

Related

Rails gcal4ruby gem uninitialized

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.

ruby on rails authentication using devise gem

Am using devise gem for authentication
When i run rake db:migrate
I got the error mentioned below:
rake aborted!
User does not respond to 'devise' method.
This usually means you haven't loaded your ORM file or it's being loaded too late.
To fix it, be sure to require 'devise/orm/YOUR_ORM' inside 'config/initializers/devise.rb'
or before your application definition in 'config/application.rb'
If you know answer. Please let me know..
In the file config/initializers/devise.rb look for the line:
require 'devise/orm/active_record'
Make sure that it isn't commented out, and make sure it matches your orm.
If that file doesn't exist, then you haven't installed devise:
rails generate devise:install
Have a good read of the Getting Started instructions

RoR using Devise - Encrypted Password

Hi pardon my ignorance but I'm new to RoR. My problem is that I'm trying to make my Devise gem work but when I fill out the information and click Sign-Up, I get this in return: "undefined method `encrypted_password=' for".
I've already tried rake db:migrate and also clearing the attributes in the User.rb model but still it doesn't work.
Please any guidance would be appreciated!
This most likely means, that you are missing on migrations.
Are you sure, that you have setup devise right?
https://github.com/plataformatec/devise
rails generate devise:install
rails generate devise User
bundle exec rake db:migrate
In the rails console run, this will tell you if the migration has run
User.new.respond_to?(:encrypted_password=)
This should return true, if not do
bundle exec rake db:migrate:reset
In the site railscasts.com you can watch:
http://railscasts.com/episodes/209-introducing-devise
after that you understand where you make a mistake
If you then get an error - write comments and we help
P.S. gem 'devise', '1.1.rc0' => gem 'devise' in gemfile

undefined method rails 3.2.9 and devise 1.0.11

Error:
C:/Ruby193/lib/ruby/gems/1.9.1/gems/devise-1.0.11/lib/devise.rb:89:in '': undefined method 'weeks' for 2:Fixnum (NoMethodError)
That error is thrown whenever I try to run 'rails g devise:install' in a rails project I've been working on.
Any ideas?
P.S. requiring gem 'devise' in Gemfile and running bundle install to get the devise gem
This issue was already dealt with here. Try updating to a later devise version to fix.

Rails sitemap_generator Uninitialized Constant?

I'm trying to use the Rails site map_generator gem to generate site maps for a 8,000,00 page site. The gem can be found here: https://github.com/kjvarga/sitemap_generator
Here is my code in sitemap.rb:
require 'rubygems'
require 'sitemap_generator'
# Set the host name for URL creation
SitemapGenerator::Sitemap.default_host = "http://www.mysite.com"
SitemapGenerator::Sitemap.create do
add '/content.aspx?page=privacypolicy'
Product.find_each do |product|
add product_path(ppid), :lastmod => content.updated_at
end
end
However, when I run
>> ruby sitemap.rb
I get an error that says:
sitemap.rb:9:in `block in ': uninitialized constant
SitemapGenerator::Interpreter::Product (NameError)
However "Product" is the correct name of my model. Why is this happening?
I'm running Rails 3.1.2 and Ruby 1.9.
I'm the author of the gem. Better to open an issue on the GitHub page in future. SitemapGenerator does work in Rails 3 and Ruby 1.9.*. If you are running Rails, you don't need these lines:
require 'rubygems'
require 'sitemap_generator'
Also you generate your sitemaps by running Rake:
rake sitemap:refresh:no_ping
What is happening in your case is that because you're not running through Rake, the script does not know about the Product class, since your Rails environment hasn't been loaded.
Well, I wasn't able to get this gem working. My guess is that it doesn't work on Rails 3.1.2 or with Ruby 1.9. However, I was able to get another gem (big_sitemap) to work. Here is the link to it.
https://github.com/alexrabarts/big_sitemap

Resources