Forum: Ruby on Rails Validation with Ruby on Rails

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Db42cf321b071c91db03bf38c928c7fa?d=identicon&s=25 Jonathan Carter (taieech)
on 2007-01-06 09:03
Simple subject eh?  Probably a simple answer too!

Here is my code in the app/models/product.rb file.

class Product < ActiveRecord::Base
   validates_presence_of :title, :description, :image_url

However, it doesn't validate the form when I submit it, it will enter
the form as if there is stuff there... Wtf is going on?

I am working with the Agile web dev with rails book, and this is where I
am at currently... except I cant get past that.

Isn't the model layer where everything is passed through?
54079122b67de9677c1f93933ce8b63a?d=identicon&s=25 Mitchell Hashimoto (Guest)
on 2007-01-06 09:29
Yes, it should validate it. How do you save your data? Can you post the
code you used. Some methods of saving will bypass validation.
Db42cf321b071c91db03bf38c928c7fa?d=identicon&s=25 Jonathan Carter (taieech)
on 2007-01-06 09:32
lol its very simplistic..

class AdminController < ApplicationController
        scaffold :product

See? :O
This topic is locked and can not be replied to.