On May 25, 1:00 pm, Newb Newb <[email protected]>
wrote:
> I have a phone field in my table.
> But in my form i have two text boxes to get the phone number and the
> country code like below
>
> Enter country code -----  Enter phone code ------
>
> In my table i have to save the phone code field after joining the above
> values with "-" symbol.
>
> Example =>  0225-25874255
>
> I dont have table field for country_code .
> So i created like below
> attr_accessor :phone , :country_code

You don't need attr_accessor for :phone since you already have a phone
column (if i understand correctly). When used like this attr_accessor
overwrites the accessors that ActiveRecord provides.

Fred
> I have given for validation like below
>
>  validates_presence_of :country_code,
>                          :message => '*The country code is required.'
>
> @user = UserInfo.new()
> phone_code = params[:userinfo][:country_code] +'-'+
> params[:userinfo][:phone_code]
> @user.name = params[:userinfo][:name]
> @user.phone = phone_code
> @user.save
> when i save,my phone field is blank...
> what i m doing wrong..
> pls guide me.
> --
> Posted viahttp://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
-~----------~----~----~----~------~----~------~--~---

Reply via email to