Validation with Ruby on Rails


#1

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
end

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?


#2

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.


#3

lol its very simplistic…

class AdminController < ApplicationController
scaffold :product
end

See? :open_mouth: