Validation Error

Hi all,

I’m trying to validate a data field.

I’ve added ‘validate_presence_of :name’ to the record model, but when I
try to create a record i get an error complaining that it can’t find
data from another table that also is updated on that page.

Let me explain further,

On my ‘record’ update page, I have data from another table displayed.
When i try to validate the ‘record’ data, an error is thrown complaining
that it can’t find the data from the other table?

Any insight would be appreciated,

Ice

On 7/6/06, Ice [email protected] wrote:

On my ‘record’ update page, I have data from another table displayed.
When i try to validate the ‘record’ data, an error is thrown complaining
that it can’t find the data from the other table?

Any insight would be appreciated,

Ice

If it’s not sensitive I think the list could use a little bit of code
and maybe a database schema for the tables. And especially the exact
error you’re getting.

Cheers,
Chuck V.

If it’s not sensitive I think the list could use a little bit of code
and maybe a database schema for the tables. And especially the exact
error you’re getting.

Cheers,
Chuck V.

Hi Chuck,

Sorry for the lack of detail… here’s what my situation is.

I’ve added

----recordModel-----------
validates_presence_of :name

----recordController
def new
@record = Record.new
@product = Product.find(@params[‘product_id’])
end

def create
@record = Record.new(@params[‘record’])
@record.save
end

----newRecord.rhtml
New record for <%= @product.number %>

Enter in record name

-----error complains:------------
You have a nil object when you didn’t expect it!
The error occured while evaluating nil.number

(which is in reference to product.nubmber)

Please let me know if you need more detail

Mike

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs