>> I have this in users_controller.rb
>> -----------------------------------------
>> @user = @company.users.build(params[:user])
>> @user.invitation_last_sent_at = Time.now
>> @user.invitation_last_sent_to = ???????
>
> What? You have that line if the controller?
No, I meant I tried those 3 different lines in different times. Here's
the create method in the users_controller.rb
-------------------------------------------
def create
@company = Company.find(params[:company_id])
@user = @company.users.build(params[:user])
@user.user_state = "invited"
@user.invitation_last_sent_at = Time.now
@user.invitation_last_sent_to = @user.email
respond_to do |format|
if @user.save
Notifier.user_invited(@user).deliver
format.html { redirect_to(users_url, :notice => user_long_name) }
format.xml { render :xml => @user, :status => :created, :location
=> @company }
else
format.html { render :action => "new" }
format.xml { render :xml => @company.errors, :status =>
:unprocessable_entity }
end
end
end
---------------------------
I did find I was getting a "mass-assign" error in the server log, so I
added the attribute to attr_accesssible in user.rb
----------------------------------
attr_accessible :email,
:first_name,
:last_name,
:invitation_last_sent_at
[... more attributes ...]
-----------------------------------
the mass-assign error went away but invitation_last_sent_to it's still
nil.
I already tried in the console.
------------------------------------
irb(main):001:0> u = User.new
=> #<User id: nil, email: nil, password_hash: nil, password_salt: nil,
created_at: nil, updated_at: nil, company_id: nil, first_name: nil,
last_name: nil, title: nil, username: nil, user_state: nil,
confirmation_token: nil, confirmed_at: nil, auth_token: nil, role_id:
nil, invitation_last_sent_at: nil, invitation_last_sent_to: nil>
irb(main):002:0> u.email = "[email protected]"
=> "[email protected]"
irb(main):003:0> u.invitation_last_sent_to = u.email
=> "[email protected]"
----------------------------------------------------------
So it's working in the CONSOLE but not in the APP. I'm sure there is
something else in my code that it's making it nil, will keep on looking.
--
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.