search for: on_update

Displaying 4 results from an estimated 4 matches for "on_update".

2006 Jun 12
2
on_update current_timestamp in Migrations
Is there any way to set database columns to auto update a timestamp column on update? Can I do something like t.column "timestamp", :datetime, :default => :current_time, :null => false, :on_update => :current_timestamp or do i need to just use custom sql like sql = "ALTER TABLE `table` CHANGE `timestamp` `timestamp` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP" exectue sql Any help is appreciated. Thanks. -- Posted via http://www.ruby-forum.co...
2006 Jun 21
1
Migration with foreign key won''t work
...t, :text end create_table :artist_types, :force => true do |t| t.column :artist_type, :string, :limit => 20 t.column :description, :string, :limit => 20 end # Foreign Keys add_foreign_key_constraint :artists, :artist_type_id, :artist_types, :artist_type, :on_update => :cascade, :on_delete => :restrict # artists(artist_type_id) references artist_types(artist_type) end def self.down drop_table :artists drop_table :artist_types # Foreign Keys remove_foreign_key_constraint :artists, :foreign_key => :artist_type_id end end When...
2006 Mar 13
3
validates_associated problem
...;department'' and have setup the relationship as follows. class Employee < ActiveRecord::Base belongs_to :department, :foregin_key => "department_id" validates_associated :department_id end class Department < ActiveRecord::Base has_many :employees def validate_on_update unless self.find_by_id(id) error.add(:id, "is invalid department") end end However when I try to save an employee with some test department ''578'', get the following error because of validates_associated in employee "undefined method `valid?'' for &...
2008 Feb 03
1
ActiveRecord object.valid? triggers unexepected results
...n ActiveRecord object in a session through AJAX, updating it with object.attributes = params[:object], and validating it with object.valid? Because it''s associated with other objects in a form, I want to save them all together. The surprise was that object.valid? triggers after_validation_on_update. I''m having an audit log and I was getting bogus entries. http://api.rubyonrails.org/classes/ActiveRecord/Validations.html#M001316 valid?() Runs validate and validate_on_create or validate_on_update and returns true if no errors were added otherwise false. valid?() should run all validat...