On Tue, Jun 25, 2013 at 7:48 PM, monte olvera <[email protected]> wrote:
>> Did you remember to set "config.authentication_keys = [:username]" in >> the initializer? Show us at least the non-commented-out lines. > $ grep -v \# config/initializers/devise.rb |grep . Ah, we're obviously not dealing with a total programming-newbie here! :-) > config.case_insensitive_keys = [ :username ] > config.strip_whitespace_keys = [ :username ] ... > config.authentication_keys = [ :username ] > config.reset_password_keys = [ :username ] > config.confirmation_keys = [ :username ] Okay, so far so good. Just to be sure, I compared it with one of my apps that uses username to log in, and the only other mention of username I had was config.unlock_keys (which you might not be using at all). >> That sounds like you may be pulling out the wrong part of the params. >> Can you show us the controller action and logged params? Or are you >> just using the default Devise controllers? > > I apologize if I'm not following you, because I'm new to Ruby on Rails, > but Devise didn't install any Controller, Actually, it does, just not placed in with your own controllers. In its own directory, it has controllers and views and so on. Gems provide Rails additional places to find such things. Some, such as Devise, also let you install stuff into your app's code dirs so that you can mess with them. (I'm guessing you did that with its views, in order to make it ask for first and last name instead of email.) Some don't, and are meant to run strictly out of their own dirs (modulo the configuration initializer). > I assume I'm using the default. I'd agree. > However I did add an entry to my application's > controller so I could authenticate before going to any page: > > $ cat app/controllers/my_app_controller.rb > class MyAppController < ApplicationController > before_filter :authenticate_user! That should be fine. > When I was looking through the logs (to respond to your "logged params" > question I found this error: The rest of it looks good, confirming you're sending the right stuff to the right place. > WARNING: Can't mass-assign protected attributes for User: password" > > So, I googled it and saw references to removing the "attr_protected > :password" from the model (user.rb). Yes, that's fairly important to understand. Another idea, though, is to get a bit ahead of the curve, and use Rails 4 with its "strong parameters". 4 was just released today, so it's now officially stable so you can build with it confidently. Also, if you're trying to get actual paid work in it, it's new enough that the competition will have some struggles too, which evens the playing field a bit against grizzled veterans like me. Oh, wait, never mind, stick with Rails 3, better yet go check out Rails 2, pay no attention to the release no longer behind the curtain.... ;-) > I did that and now only get the "Email can't be blank" > error when trying to sign up a user. Ah, good progress. Maybe there's still a validation looking for email in your User class? Can you post that? You could also go on a "search and destroy" mission: find all mentions of email in your app and examine them to see if they could be the cause. (Do you know about the "ack" utility?) Come to think of it, there's a much simpler possibility; it may sound stupid, but we've all done it. Maybe you didn't restart your Rails server after modifying Devise. You need to do that to make it reread the initializers, such as the one that tells Devise what fields to use as keys. -Dave -- Dave Aronson, the T. Rex of Codosaurus LLC, secret-cleared freelance software developer taking contracts in or near NoVa or remote. See information at http://www.Codosaur.us/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAHxKQigLxW0pgn22sYm6ar4qgC3O7f1Kp0sdFjrjx2JLxbug7g%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.

