I have a Diu model class Diu < ActiveRecord::Base has_many :lalas end Then I have a Keke model class Keke < ActiveRecord::Base #blah end class Lala < Keke belongs_to :diu validates_presence_of :diu_id end Then I have a LalaController class LalaController < ApplicationController def new @lala = Lala.new render :partial => ''new'' end def create @lala = Lala.new(params[:lala]) @lala.save! redirect_to :action => ''show'', :id => @lala end end Now, whenever I go ahead and try to save my lala, I get a validation error because the :diu_id doesn''t get carried aboard. I''ve been trying to figure out how can I get it come aboard for approx a year now. I also have the book (AWDR), but since it hasn''t been much help so far I might as well burn it. Help me Obi-Wan Kenobi(s), you''re my only hope. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
morbusg wrote:> class Lala < Keke > belongs_to :diu > validates_presence_of :diu_id > end > > Now, whenever I go ahead and try to save my lala, I get a validation > error because the :diu_id doesn''t get carried aboard. I''ve been trying > to figure out how can I get it come aboard for approx a year now. I > also have the book (AWDR), but since it hasn''t been much help so far I > might as well burn it. > > Help me Obi-Wan Kenobi(s), you''re my only hope.The Force is strong with you my friend, but you''ll really want to validate_presence_of :diu instead of :diu_id. -- Roderick van Domburg http://www.nedforce.nl -- 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 -~----------~----~----~----~------~----~------~--~---
morbusg wrote:> I have a Diu model > class Diu < ActiveRecord::Base > has_many :lalas > end > > Then I have a Keke model > class Keke < ActiveRecord::Base > #blah > end > > class Lala < Keke > belongs_to :diu > validates_presence_of :diu_id > end > > Then I have a LalaController > class LalaController < ApplicationController > def new > @lala = Lala.new > render :partial => ''new'' > end > > def create > @lala = Lala.new(params[:lala]) > @lala.save! > redirect_to :action => ''show'', :id => @lala > end > end > > Now, whenever I go ahead and try to save my lala, I get a validation > error because the :diu_id doesn''t get carried aboard. I''ve been trying > to figure out how can I get it come aboard for approx a year now. I > also have the book (AWDR), but since it hasn''t been much help so far I > might as well burn it.You need something on your form that allows the user to select a Diu, like from a select list. -- Michael Wang --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---