How to fetch crucial info

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.

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

morbusg wrote:

class Lala < Keke

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 W.