Re: Shouldn''t this insert in table?

Frederick Cheung
Thu, 03 Sep 2009 11:09:49 -0000

On Sep 3, 12:00 pm, RVince
<rvinc...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org>
wrote:
> It doesn;t save and the log reads:
>
> NoMethodError (undefined method `MyB'' for
#<MyAController:0x664f93c>):
>   app/controllers/mya_controller.rb:174:in `cxl''
>

You could have said that first time round.
Your code reads

MyB myB = MyB.new

I assume you''re more familiar with a language where you have to type
and declare variables and this is what you''re doing. ruby
doesn''t do
that though (and probably parses it as MyB(myB = MyB.new)

Fred

> But I DO have a MyB model:
>
> class MyB < ActiveRecord::Base
> end
>
> as well as a MyBsController:
>
> class MyBsController < ApplicationController
> end
>
> Im confused regarding ActiveRecord here -- I''m just trying to add
a
> record into the table associate with MyB from MyAsController. -RVince