Kapil Kaligotla
2012-Jan-30 05:31 UTC
data is storing in database when i had created but it is destroyed after the sign out
I had created users using devise in rails. I am storing user mobile
number and land line number for the user profile, by using this code
it is storing the cell and land line numbers in database but after the
sign out it is not stored in the database. please tell me whats wrong
in my code in users.rb
before_save :build_telephone
before_save :build_cell
validates :code, :presence => true, :numericality => true, :length =>
{ :within => 1..2 }, :on => :update
validates :code2, :presence => true, :numericality => true, :length
=> { :within => 2..4 }, :on => :update
validates :number, :presence => true, :numericality => true, :length
=> { :within => 1..7 }, :on => :update
validates :code1, :presence => true, :numericality => true, :length
=> { :within => 1..2 }, :on => :update
validates :number1, :presence => true, :numericality =>
true, :length => {:minimum => 10, :maximum => 10}, :on => :update
attr_accessor :code,:code2, :number, :code1, :number1
attr_accessible :email, :password, :password_confirmation, :mobile, :landline,
:remember_me , :code, :code2, :number, :code1, :number1
def build_cell
self.mobile = "#{self.code1}-#{self.number1}"
end
def build_telephone
self.landline = "#{self.code}-#{self.code2}-#{self.number}"
end
--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Neethu Satheesh
2012-Jan-30 06:03 UTC
Re: data is storing in database when i had created but it is destroyed after the sign out
Hi Kapil,
Please try with self.save in your methods build_cell & build_telephone.
Eg :
def build_cell
self.mobile = "#{self.code1}-#{self.number1}"
self.save
end
Thanks,
Neethu
--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Kapil Kaligotla
2012-Jan-30 06:14 UTC
Re: data is storing in database when i had created but it is destroyed after the sign out
Hi, Thanks for your quickest response, i had added the self.save but i am getting error as "stack level too deep" on submitting the profile form Thanks, Kapil On Jan 30, 11:03 am, Neethu Satheesh <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi Kapil, > > Please try with self.save in your methods build_cell & build_telephone. > > Eg : > > def build_cell > self.mobile = "#{self.code1}-#{self.number1}" > self.save > end > > Thanks, > > Neethu > > -- > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Neethu Satheesh
2012-Jan-30 06:20 UTC
Re: data is storing in database when i had created but it is destroyed after the sign out
Try following this thread, I have not it read completely. It may help you. - Neethu -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Neethu Satheesh
2012-Jan-30 06:21 UTC
Re: data is storing in database when i had created but it is destroyed after the sign out
Try following this thread, I have not it read completely. It may help you. http://www.ruby-forum.com/topic/3233401 - Neethu -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Prince Joseph
2012-Jan-30 06:31 UTC
Re: data is storing in database when i had created but it is destroyed after the sign out
I believe one of the validations is failing in the case where you update
the user profile. Try using something with bang operator(like
''save!'') in
the code where you update the user profile (in the controller) to identify
which validation is failing. (''!'' will raise an exception if
any validation
is failed).
On Mon, Jan 30, 2012 at 11:01 AM, Kapil Kaligotla <
kapil.kaligotla-C8lSLueJBA4oM3ANB2zruQ@public.gmane.org> wrote:
> I had created users using devise in rails. I am storing user mobile
> number and land line number for the user profile, by using this code
> it is storing the cell and land line numbers in database but after the
> sign out it is not stored in the database. please tell me whats wrong
> in my code in users.rb
>
>
> before_save :build_telephone
> before_save :build_cell
>
> validates :code, :presence => true, :numericality => true, :length
=>
> { :within => 1..2 }, :on => :update
> validates :code2, :presence => true, :numericality => true, :length
> => { :within => 2..4 }, :on => :update
> validates :number, :presence => true, :numericality => true, :length
> => { :within => 1..7 }, :on => :update
> validates :code1, :presence => true, :numericality => true, :length
> => { :within => 1..2 }, :on => :update
> validates :number1, :presence => true, :numericality =>
> true, :length => {:minimum => 10, :maximum => 10}, :on =>
:update
>
> attr_accessor :code,:code2, :number, :code1, :number1
>
> attr_accessible :email, :password, :password_confirmation, :mobile,
> :landline, :remember_me , :code, :code2, :number, :code1, :number1
>
> def build_cell
> self.mobile = "#{self.code1}-#{self.number1}"
> end
>
> def build_telephone
> self.landline = "#{self.code}-#{self.code2}-#{self.number}"
> end
>
> --
> 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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
>
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
Thanks,
Prince
--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Prince Joseph
2012-Jan-30 06:38 UTC
Re: Re: data is storing in database when i had created but it is destroyed after the sign out
You should not add ''self.save'' to the method, as you are calling these functions in ''before_save''. It means these functions will be invoked before saving any object of that model. Calling ''self.save'' inside it will result in an infinite loop. On Mon, Jan 30, 2012 at 11:44 AM, Kapil Kaligotla < kapil.kaligotla-C8lSLueJBA4oM3ANB2zruQ@public.gmane.org> wrote:> Hi, > Thanks for your quickest response, i had added the self.save but i > am getting error as "stack level too deep" on submitting the profile > form > > Thanks, > Kapil > > On Jan 30, 11:03 am, Neethu Satheesh <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > Hi Kapil, > > > > Please try with self.save in your methods build_cell & build_telephone. > > > > Eg : > > > > def build_cell > > self.mobile = "#{self.code1}-#{self.number1}" > > self.save > > end > > > > Thanks, > > > > Neethu > > > > -- > > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- Thanks, Prince -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.