search for: add_on_empty

Displaying 6 results from an estimated 6 matches for "add_on_empty".

2006 Feb 21
8
Validations continued
...] = ''Client was successfully created.'' redirect_to :action => ''list'' else render :action => ''new'' end end Model # includes the following validates_presence_of :first_name protected def validate errors.add_on_empty %w(first_name) end And if I try to enter a new ''client'' missing the first name, it sends me to trace error page but doesn''t capture it as it suggests in Agile book. This is making me crazy and is a continuation of my issue from last night which a decent night sleep an...
2006 Aug 10
4
I need "validates_presence_of" help
Hi - I have 3 fileds a user can fill out. They can fill out 2 of them or just one of them, for example. fill out these 2 fields: Field1 and Field2 Or fill out this field: Field3 In my model how do I use validates_presence_of for Field1 and Field2 or just Field3. I want to do something like this: validates_presence_of Field1, Field2 OR validates_presence_of Field3 So the user can fill out
2005 Feb 19
0
[Error] Using validates_presence_of for datetime field causes parse error?
.../1.8/gems/activerecord-1.6.0/lib/active_record/ base.rb:1031:in `method_missing'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.6.0/lib/active_record/ validations.rb:443:in `send'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.6.0/lib/active_record/ validations.rb:443:in `add_on_empty'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.6.0/lib/active_record/ validations.rb:442:in `each'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.6.0/lib/active_record/ validations.rb:442:in `add_on_empty'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.6.0/lib...
2005 Feb 28
5
Using session data in model
...and then dependent of the gender, there''s different fields that needs validation. I''m wondering what''s the preffered way of doing this. The session data is not present in the model, i.e: class Myclass < ActiveRecord::Base belongs_to :member def validate errors.add_on_empty %w{ required_field } if @session["member"].gender == ''m'' end end does not work since the @session["member"] variable is not set. I''ve tried to set: @member = @session["member"] in my controller before I call Myclass.save and that doesn&...
2006 May 04
2
validates :on 2
Hello, I need to have this for :create and :login how do I do so validates_presence_of :login, :password, :password_confirmation, :user_name, :email, :on => :create I do need it to be off in a number of places though -- Posted via http://www.ruby-forum.com/.
2006 May 23
11
putting the schema in the model files
THE SCHEMA IN THE MODEL a small write up on ''putting the schema in the model'' This is a write up on an issue best covered in a mailing list thread of Januari 2006 (see the links in the text), I repost it because I think it deserves a place on the agenda. == Why? == I was switching back and forward between the model files and the schema.rb -- off course I have