Hi everyone,
I am a total novice with Ruby on Rails and I’m having a problem using
validates_presence_of. I’m following a tutorial from a book called
“Ruby on rails: up and running” and I’m not getting the result I expect
(and what the book expects).
Here’s my model:
class Photo < ActiveRecord::Base
validates_presence_of :filename
end
I tested this using rails console:
photo=Photo.new
=> #<Photo id: nil, filename: nil>photo.save
=> trueputs photo.filename
nil
I expect (and so does the book) that photo.save returns false and
nothing is saved to the database, but it saves anyway. Any ideas what I
am doing wrong? Forgive me if it’s something ridiculously simple that
I’ve overlooked, it is quite late
If you could point me in the right direction I would be greatly
appreciative.
Cheers,
Adam