Re: Validation and models

2011-01-07 Thread Jeremy Evans
On Jan 7, 2:07 am, Piotr don.pi...@yahoo.it wrote:
 Hi,

 I really don't understand why model's validation.
 In form i have many camps that don't exist in database,
 or it's value have to be processed before i put it in database.

 Examples: password that i have to encode;
 password confirmation that i have to look is it right;
 data camps (one for days, one for month, one for year) i have to join
 in one variable.

 For sure there are many other examples.

 Everything of that I have to do before I sand values to my model.
 So all valdation I should make outside of model.

 Somebody can explain for my this.

Model validation is purely optional, no validations are done by
default.  If you want to use external validations before putting data
in the model, that's perfectly fine.

That being said, most users choose to use internal model validations,
which still validate data before sending it to the database.

IMO, model validation at the ruby level is purely about giving nice
error messages to the users.  Robust applications should be using
database constraints for data integrity where possible.

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
sequel-talk group.
To post to this group, send email to sequel-t...@googlegroups.com.
To unsubscribe from this group, send email to 
sequel-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.



Re: MySQL reconnection

2011-01-07 Thread Aman Gupta
On Fri, Jan 7, 2011 at 2:54 AM, Roland Swingler
roland.swing...@gmail.comwrote:

  This code looks like you are attempting to disconnect after the fork,
  instead of before forking.  Also, you don't need to call
  Sequel.connect again, just DB.disconnect should be enough.  But make
  sure it is called before forking, not after.

 Ah - so is reconnecting to the DB handled for me by the connection
 pool as soon as I try to use the Database object (I tried in the
 console and it seems to work that way)?

 The problem here is that I don't think I have any way of running code
 before fork is called, because it isn't a Daemon I'm writing myself,
 but Passenger. As far as I can tell from the passenger documentation,
 this is the only point at which I can hook into the passenger forking/
 spawning method.


I am using DB.disconnect
inside PhusionPassenger.on_event(:starting_worker_process) without any
issues.

  Aman



 I'm probably being really dense, but why is it important to disconnect
 before rather than after the fork?

 AFAIK, the connection won't actually ever be used in the parent
 process (a passenger ApplicationSpawner), only in child processes -
 does this make a difference as to whether it matters whether you
 disconnect pre/post fork?

 Maybe this is more of a issue for the passenger mailing list.

 @Aaron
  don't forget that there may be a stateful
  firewall that is expiring state and denying packets (thus causing the
  disconnect).

 I don't think this is the problem because I have a rails app working
 on the same setup which works fine.


 Thanks for everyone's help so far, much appreciated.

 Cheers,
 Roland

 --
 You received this message because you are subscribed to the Google Groups
 sequel-talk group.
 To post to this group, send email to sequel-t...@googlegroups.com.
 To unsubscribe from this group, send email to
 sequel-talk+unsubscr...@googlegroups.comsequel-talk%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/sequel-talk?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
sequel-talk group.
To post to this group, send email to sequel-t...@googlegroups.com.
To unsubscribe from this group, send email to 
sequel-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.