Hi, I''ve successfully used: @presentation = current_user.presentation @presentation = current_user.create_presentation unless @presentation before in my code when creating a new user (in the users_controller) to create an "empty" presentation table. This does not work when I copy the above code and replace "presentation" with "spec", even though there should be no other differances for implementing it. The Specs db-table is built in the same way, containing the same properties for default, not null?, unsigned?, Zerofil?. All which are empty. My relations are right (as far as I can see) User.rb "has_one :spec" Spec.rb "belongs_to :user" This is such a stupid error, forcing me to manually fill the Specs table to get it to work. What can be wrong? -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
My Log shows that it refuses to use INSERT INTO in spec. presentation: [4;35;1mPresentation Columns (0.000000) [0m [0mSHOW FIELDS FROM presentations [0m [4;36;1mSQL (0.000000) [0m [0;1mBEGIN [0m [4;35;1mSQL (0.000000) [0m [0mINSERT INTO presentations (`user_id`, `pres`) VALUES(11, NULL) [0m [4;36;1mSQL (0.031000) [0m [0;1mCOMMIT [0m spec: [4;36;1mSpec Load (0.000000) [0m [0;1mSELECT * FROM specs WHERE (specs.user_id = 11) LIMIT 1 [0m [4;35;1mSpec Columns (0.016000) [0m [0mSHOW FIELDS FROM specs [0m [4;36;1mSQL (0.000000) [0m [0;1mBEGIN [0m [4;35;1mSQL (0.000000) [0m [0mCOMMIT [0m -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 2 Apr 2008, at 10:06, Dag Stensson wrote:> > Hi, > > I''ve successfully used: > > @presentation = current_user.presentation > @presentation = current_user.create_presentation unless @presentation > > before in my code when creating a new user (in the users_controller) > to > create an "empty" presentation table. > > This does not work when I copy the above code and replace > "presentation" > with "spec", even though there should be no other differances for > implementing it.Could there be validations on spec that are failing ? Fred> > > The Specs db-table is built in the same way, containing the same > properties for default, not null?, unsigned?, Zerofil?. All which are > empty. > > My relations are right (as far as I can see) > User.rb "has_one :spec" > Spec.rb "belongs_to :user" > > This is such a stupid error, forcing me to manually fill the Specs > table > to get it to work. > > What can be wrong? > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
@presentation = current_user.presentation @presentation ||= current_user.create_presentation Looks much sexier, no? --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On 2 Apr 2008, at 10:06, Dag Stensson wrote: > >> create an "empty" presentation table. >> >> This does not work when I copy the above code and replace >> "presentation" >> with "spec", even though there should be no other differances for >> implementing it. > > Could there be validations on spec that are failing ? > > FredYeah, Thanks Fred! You were absolutely right! I had a few validations failing since the rows are empty. ;D Removing the validations solves it, but I want to use the validations later on when I update...So I kept them, is there any way to bypass the validations once? I tried this but that didn''t solve it. @spec = Spec.new @spec.save(false) @user.spec = @spec @user.save -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 2 Apr 2008, at 14:06, Dag Stensson wrote:>> >> Could there be validations on spec that are failing ? >> >> Fred > > Yeah, Thanks Fred! You were absolutely right! I had a few validations > failing since the rows are empty. ;D > > Removing the validations solves it, but I want to use the validations > later on when I update...So I kept them, is there any way to bypass > the > validations once?You can set validations to run only on update (validates_foo :on => :update) Fred> > > I tried this but that didn''t solve it. > > @spec = Spec.new > @spec.save(false) > @user.spec = @spec > @user.save > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On 2 Apr 2008, at 14:06, Dag Stensson wrote: >> the >> validations once? > > You can set validations to run only on update (validates_foo :on > => :update) > > FredIf you meant like this it doesn''t work, otherwise I''d appriciate if you''d be more exact (I''m sort of a newbee still) [...in spec.rb...] validates_format_of :zip_code, :with => /(^$|^[0-9]{#{ZIP_CODE_LENGTH}}$)/, :on => :update, :message => "must be a five digit number" -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I''ve narrowed it down to ONE validation which doesn''t work
validates_inclusion_of :gender,
:on => :update,
:in => VALID_GENDERS,
:allow_nil => true,
:message => "must be male or female"
--
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---