Validation with Ruby on Rails


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?


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.


lol its very simplistic…

class AdminController < ApplicationController
scaffold :product

See? :open_mouth: