timwaters / mapwarper

free open source public map georeferencer, georectifier and warper
http://mapwarper.net
MIT License
196 stars 80 forks source link

NoMethodError: undefined method `activate!' for #<User:0x00000006096888> #85

Closed duhaime closed 7 years ago

duhaime commented 8 years ago

When following the quickstart directions using Vagrant, I create a User following the instructions, but when I issue user.send(:activate!) I get NoMethodError: undefined methodactivate!' for #User:0x00000006096888`. I'm on OSX with Vagrant 1.8.1. Am I missing something?

Here's the full transaction:

vagrant@vagrant-ubuntu-trusty-64:/srv/mapwarper$ rails c
Warning: You're using Rubygems 1.8.23 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all` for better startup performance.
Loading development environment (Rails 4.2.1)
irb(main):001:0> user = User.new
=> #
irb(main):002:0> user.login = "super"
=> "super"
irb(main):003:0> user.email = "super@superxyz123.com"
=> "super@superxyz123.com"
irb(main):004:0> user.password = "your_password"
=> "your_password"
irb(main):005:0> user.password_confirmation = "your_password"
=> "your_password"
irb(main):006:0> user.save
   (0.3ms)  BEGIN
  User Exists (0.9ms)  SELECT  1 AS one FROM "users" WHERE "users"."email" = 'super@superxyz123.com' LIMIT 1
  User Exists (0.4ms)  SELECT  1 AS one FROM "users" WHERE (LOWER("users"."login") = LOWER('super') AND "users"."email" = 'super@superxyz123.com') LIMIT 1
  User Load (0.2ms)  SELECT  "users".* FROM "users" WHERE "users"."confirmation_token" = $1  ORDER BY "users"."id" ASC LIMIT 1  [["confirmation_token", "4efe04d6ebe90bcb8b86422c00d76682e473dfa48e10b1b22b7d1a863772ab03"]]
  SQL (0.5ms)  INSERT INTO "users" ("login", "email", "password_salt", "encrypted_password", "created_at", "updated_at", "confirmation_token", "confirmation_sent_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id"  [["login", "super"], ["email", "super@superxyz123.com"], ["password_salt", "oBJLCtz2jrYorjxPGqWC"], ["encrypted_password", "{SHA}Vk40DNSEN9Lf6HbuFUzJncTQ0Tc=\n"], ["created_at", "2016-03-04 00:49:24.327620"], ["updated_at", "2016-03-04 00:49:24.327620"], ["confirmation_token", "4efe04d6ebe90bcb8b86422c00d76682e473dfa48e10b1b22b7d1a863772ab03"], ["confirmation_sent_at", "2016-03-04 00:49:24.548890"]]
  Rendered devise/mailer/confirmation_instructions.html.erb (4.2ms)

Devise::Mailer#confirmation_instructions: processed outbound mail in 450.4ms
sh: 1: /usr/sbin/sendmail: not found

Sent mail to super@superxyz123.com (100.7ms)
Date: Fri, 04 Mar 2016 00:49:25 +0000
From: example_user@example.com
Reply-To: example_user@example.com
To: super@superxyz123.com
Message-ID: <56d8db9511ca8_66212b8800200d5@vagrant-ubuntu-trusty-64.mail>
Subject: Map Warper email address confirmation instructions
Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

Welcome super@superxyz123.com!

Thanks for signing up to use MapWarper. Please confirm your email to continue the sign up process.

MapWarper is a site where you can discover, georeference and upload your own maps and imagery. You can georectify or warp the map to base map to be able to use the map in new ways. You can download the georeferenced image in a number of formats including KML, WMS and Tiles.

You can confirm your account email through the link below:

Confirm my account

(0.5ms) COMMIT => true irb(main):007:0> user.send(:activate!) NoMethodError: undefined method `activate!' for # from /var/lib/gems/1.9.1/gems/activemodel-4.2.1/lib/active_model/attribute_methods.rb:433:in `method_missing' from (irb):7 from /var/lib/gems/1.9.1/gems/railties-4.2.1/lib/rails/commands/console.rb:110:in `start' from /var/lib/gems/1.9.1/gems/railties-4.2.1/lib/rails/commands/console.rb:9:in `start' from /var/lib/gems/1.9.1/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:68:in `console' from /var/lib/gems/1.9.1/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!' from /var/lib/gems/1.9.1/gems/railties-4.2.1/lib/rails/commands.rb:17:in `' from /var/lib/gems/1.9.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require' from /var/lib/gems/1.9.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `block in require' from /var/lib/gems/1.9.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency' from /var/lib/gems/1.9.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require' from /srv/mapwarper/bin/rails:8:in `' from /var/lib/gems/1.9.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load' from /var/lib/gems/1.9.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `block in load' from /var/lib/gems/1.9.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency' from /var/lib/gems/1.9.1/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load' from /var/lib/gems/1.9.1/gems/spring-1.3.4/lib/spring/commands/rails.rb:6:in `call' from /var/lib/gems/1.9.1/gems/spring-1.3.4/lib/spring/command_wrapper.rb:38:in `call' from /var/lib/gems/1.9.1/gems/spring-1.3.4/lib/spring/application.rb:183:in `block in serve' from /var/lib/gems/1.9.1/gems/spring-1.3.4/lib/spring/application.rb:156:in `fork' from /var/lib/gems/1.9.1/gems/spring-1.3.4/lib/spring/application.rb:156:in `serve' from /var/lib/gems/1.9.1/gems/spring-1.3.4/lib/spring/application.rb:131:in `block in run' from /var/lib/gems/1.9.1/gems/spring-1.3.4/lib/spring/application.rb:125:in `loop' from /var/lib/gems/1.9.1/gems/spring-1.3.4/lib/spring/application.rb:125:in `run' from /var/lib/gems/1.9.1/gems/spring-1.3.4/lib/spring/application/boot.rb:18:in `' from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require' from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require' from -e:1:in `
'irb(main):008:0> irb(main):009:0*

I can still use http://localhost:3000/u/confirmation?confirmation_token=i4RS6_aSFnYsQ7e2uaVE to confirm the account.

timwaters commented 8 years ago

Ahh yes, this is an error with the documentation.

try user.activated_at = Time.now ? (could be confirmed_at)

duhaime commented 8 years ago

You were quite right, user.confirmed_at = Time.now sets the appropriate value in the user hash! I sent a quick pull request to update the documentation.