Ruby on Rails Tuesday, June 25, 2013

first of all, thanks man for helping me, I really appreciate it!

> Ah, we're obviously not dealing with a total programming-newbie here!
> :-)

:) I said I was new to Ruby, not to programming. Started with Qbasic
on my commodore back in 1995 when I was 10. I know Assembly, C/C++,
Python, Shell, PHP. But I digress....

> 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.

Here's what I ran to install devise:
rails generate devise:install
rails generate devise user
rails generate devise:views

> (I'm guessing you did that with its views, in
> order to make it ask for first and last name instead of email.)

Nope, I edited that myself because I couldn't find anything anywhere.

> parameters". 4 was just released today

I am using rails 4:
$ rails -v
Rails 4.0.0.rc2


> Also, if you're trying to get actual paid work in it

Ha! I better not be, my resume would read: "I googled stuff!"

Actually I want to get this (personal) project done and figured I'd go
back and learn why I did what I did and why it worked later. This goes
against everything in me but I simply don't have the time (right now) to
dedicate a month to fully learning ruby on rails before getting this
project done.

> Maybe there's still a validation looking for email in your User class?
> Can you post that?

$ grep -v \# app/models/user.rb |grep .
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable, :recoverable,
:rememberable, :trackable, :validatable, :authentication_keys =>
[:username]
validates_presence_of :firstname, :lastname, :unique => true
after_validation :createUsername
attr_accessible :username, :password, :password_confirmation,
:remember_me, :firstname, :lastname
def createUsername
firstnamePart=self.firstname[0,1].downcase
lastnamePart=self.lastname[0,5].downcase
username=lastnamePart + firstnamePart
count=0
while username.length != 7
username=username + count.to_s
count +=1
end
self.username=username
end
def self.find_first_by_auth_conditions(warden_conditions)
conditions = warden_conditions.dup
if login = conditions.delete(:login)
where(conditions).where(["lower(username) = :value OR
lower(email) = :value", { :value => login.downcase }]).first
else
where(conditions).first
end
end
end

> 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.

$ grep -ri email *|egrep -v "#|log"
app/views/devise/mailer/unlock_instructions.html.erb:<p>Hello <%=
@resource.email %>!</p>
app/views/devise/mailer/confirmation_instructions.html.erb:<p>Welcome
<%= @resource.email %>!</p>
app/views/devise/mailer/reset_password_instructions.html.erb:<p>Hello
<%= @resource.email %>!</p>
app/views/devise/mailer/reset_password_instructions.html.erb:<p>If you
didn't request this, please ignore this email.</p>
config/locales/devise.en.yml: send_instructions: 'You will receive
an email with instructions about how to reset your password in a few
minutes.'
config/locales/devise.en.yml: send_instructions: 'You will receive
an email with instructions about how to confirm your account in a few
minutes.'
config/locales/devise.en.yml: send_paranoid_instructions: 'If your
e-mail exists on our database, you will receive an email with
instructions about how to confirm your account in a few minutes.'
config/locales/devise.en.yml: send_instructions: 'You will receive
an email with instructions about how to unlock your account in a few
minutes.'
config/locales/devise.en.yml: send_paranoid_instructions: 'If your
account exists, you will receive an email with instructions about how to
unlock it in a few minutes.'
Binary file db/development.sqlite3 matches
db/schema.rb: t.string "email",
default: "", null: false
db/schema.rb: add_index "users", ["email"], name:
"index_users_on_email", unique: true
Binary file
tmp/cache/assets/development/sprockets/d585a06e2ee6203ccb04c8b84150d14d
matches
Binary file
tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705
matches
Binary file
tmp/cache/assets/development/sprockets/8c2b061e379a23e7c4d207adcf992462
matches
Binary file
tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953
matches
Binary file
tmp/cache/assets/development/sprockets/b7fc7a50cc3464d16f378714639f14e2
matches

> (Do you know about the "ack" utility?)
a rails utility? Nope, never heard of an 'ack' utility.


> Maybe you didn't restart your Rails server after modifying Devise.
I've only done that 500 times. Really, after every single change I made
I restarted rack, just in case.

--
Posted via http://www.ruby-forum.com/.

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/38006897accbf9027b5fe201c15a27d5%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment