Problem with restful_authentication

Hi

I am trying to implement restful_authentication plugin in my rails
application. But my user model contains extra fields like country_id,
state_id, city_id, phone_number, status_id, gender etc. Is it possible
to add additional fields along with restful_authentication plugin? I was
not able to store the additional fields. pls help. very urgent. This is
my first project in ROR
Thanks in advance.

The best option would be to create a user_profile and have the user
has_one :profile, :class_name => ‘user_profile’.

If you have to have it in the user class you have to add them here:

attr_accessible :login, :email, :password, :password_confirmation,
:security_question, :extra_fields

Thats what I’m guessing but I guess it depends on the error…

Did you add the extra fields using migration?

On Wed, 18 Mar 2009 14:44:33 +0100
Indu RS [email protected] wrote:

I am trying to implement restful_authentication plugin in my rails
application. But my user model contains extra fields like country_id,
state_id, city_id, phone_number, status_id, gender etc. Is it possible
to add additional fields along with restful_authentication plugin? I was
not able to store the additional fields. pls help. very urgent. This is
my first project in ROR

You’ll need to make a migration to add the extra columns to your users
table. restful_authentication generates a user model/views/controller.
So you can edit those to accept your extra fields.

SH


Starr H.
Check out my Helpdesk RailsKit: http://railskits.com/helpdesk/

Starr H. wrote:

On Wed, 18 Mar 2009 14:44:33 +0100
Indu RS [email protected] wrote:

I am trying to implement restful_authentication plugin in my rails
application. But my user model contains extra fields like country_id,
state_id, city_id, phone_number, status_id, gender etc. Is it possible
to add additional fields along with restful_authentication plugin? I was
not able to store the additional fields. pls help. very urgent. This is
my first project in ROR

You’ll need to make a migration to add the extra columns to your users
table. restful_authentication generates a user model/views/controller.
So you can edit those to accept your extra fields.

SH


Starr H.
Check out my Helpdesk RailsKit: http://railskits.com/helpdesk/

Thanks for the reply.
Created the migration and added extra fields. The error coming at the
time of saving the data to the user model. ie I am not getting the
values in the insert query (got the insert statement from the log
file).I am getting “null” for the extra fields in the insert query

On Wed, 18 Mar 2009 15:34:59 +0100
Indu RS [email protected] wrote:

Created the migration and added extra fields. The error coming at the
time of saving the data to the user model. ie I am not getting the
values in the insert query (got the

Are you sure you’re passing the extra fields to the model?

Have you tried opening a console and manually creating a user model?
That would tell you if the problem’s in your model or in your
controller/view

SH

Starr H.
Check out my Helpdesk RailsKit: http://railskits.com/helpdesk/


Starr H.
Check out my Helpdesk RailsKit: http://railskits.com/helpdesk/
Thanks again
Yes , I am sure, that I am passing the extra fields to the model.

On Wed, 18 Mar 2009 15:51:34 +0100
Indu RS [email protected] wrote:

Yes , I am sure, that I am passing the extra fields to the model.

Hmm, well it should work then :slight_smile: It might be useful for you to post some
code.

SH

Starr H.
Check out my Helpdesk RailsKit: http://railskits.com/helpdesk/

What is the error that you get? Does it say you are not allowed to
mass assign this (country_id) variable?

Have a look in your user model where you have the attr_accessible you
are going to have to add :country_id there.

Freddy A. wrote:

What is the error that you get? Does it say you are not allowed to
mass assign this (country_id) variable?

Have a look in your user model where you have the attr_accessible you
are going to have to add :country_id there.

Thank you so much for the immediate replay and solved my issue

Thanks for your valuable help.
My view code is
<% form_for @user ,:html => { :multipart => true } do |f| -%>

........ <% end %> and in my controller users_contrller in the new @user = User.new and in create actions I just wrote @user.save. The error coming in country_id cant' be null. since I had given the database constraint that null value is not allowed. while i am looking the insert statement in place of country_id value is null. but when I tried to print the params[:user][:country_id] the value is getting. Pls help. since I had spend more time and still vein .
* Username <%= f.text_field :login%>
* First Name <%= f.text_field :name%>
* E mail <%= f.text_field :email%>
* Password <%= f.password_field :password %>
* Password <%= f.password_field :password_confirmation %>
* Country <%= f.select(:country_id,Country.find(:all).collect{|c|[c.name,c.id] },:prompt=>'Select Country')%>

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs