Question

My sinatra app is showing an error when declaring required on fields using datamapper running on passenger and ruby 1.8

error: undefined local variable or method `required' for Person:Class

class Person
include DataMapper::Resource
property :id, Serial
property :salutation, String 
property :first_name, String , required => true 
property :last_name, String , required => true 
property :email, String , required => true, :format => :email_address 
property :phone, String , required => true
property :dob, String 
property :no_of_guests, String , required => true
property :attending, String, required => true

property :created_at, DateTime
end

Is this an issue with datamapper and ruby 1.8, or passenger or the way I'm decalring the required attribute?

Was it helpful?

Solution

requiredhas to be a symbol (:required):

class Person
include DataMapper::Resource
property :id, Serial
property :salutation, String 
property :first_name, String , :required => true 
property :last_name, String , :required => true 
property :email, String , :required => true, :format => :email_address 
property :phone, String , :required => true
property :dob, String 
property :no_of_guests, String , :required => true
property :attending, String, :required => true

property :created_at, DateTime
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top