Questions tagged [beforeupdate]

46 questions
18
votes
3 answers

Rails: How to run before_update only for one changed attribute?

In my model Shop I'm saving image url in logo_ori and use that to make thumbnails using before_update. # shop.rb before_update :run_blitline_job private def run_blitline_job # uses logo_ori to make thumbnails end However I found out that when…
hsym
  • 4,217
  • 2
  • 20
  • 30
4
votes
1 answer

getting old values of updated domain properties in grails

I am trying to implement the beforUpdate event in grails domain classes I need to audit log both the old and new values of the Domains attributes. I see that we can use the isDirty check or use Domain.dirtyPropertyNames which return list of…
pri_dev
  • 11,315
  • 15
  • 70
  • 122
4
votes
3 answers

How to test before_update callback in rails model with Rspec and FactoryGirl?

I am trying to test the before_update callback of the model bellow. models/option.rb: class Option < ApplicationRecord belongs_to :activity has_many :suboptions, class_name: "Option", foreign_key: "option_id" belongs_to :parent, class_name:…
3
votes
5 answers

Is there a BeforeUpdate for a C# ComboBox on a Winform

I come from the VBA world, and remember there was a BeforeUpdate call I could make on a combobox. Now I am in C# (and loving it) and I was wondering is there a BeforeUpdate call for a ComboBox on a Winform? I can make an invisible textbox and store…
Matt
  • 1,862
  • 2
  • 17
  • 19
3
votes
1 answer

Mysql triggers: check value is actually set in before insert trigger

Let's say I have a table. CREATE TABLE IF NOT EXISTS Test ( Id int(11) NOT NULL AUTO_INCREMENT, Foo tinyint(1) unsigned NOT NULL DEFAULT 0, Bar varchar(255) NOT NULL, PRIMARY KEY (Id) ); And before insert trigger: DROP TRIGGER IF EXISTS…
userlond
  • 3,632
  • 2
  • 36
  • 53
2
votes
1 answer

Why is Rails before_update callback deprecated? What's the alternative?

I looked at https://apidock.com/rails/ActiveRecord/Callbacks/before_update and it says before_update got deprecated. Does anybody know why that is and what would be the alternative? I have some code logic that needs to run specifically when an…
rails_has_elegance
  • 1,590
  • 4
  • 21
  • 37
2
votes
1 answer

Find isDirty() for children elements

I'm using Grails 3.2: class Training{ boolean clientChanged = false static transients = ['clientChanged'] static hasMany = [clients:User] //... def beforeUpdate(){ clientChanged = this.isDirty('clients') } def…
Michal_Szulc
  • 4,097
  • 6
  • 32
  • 59
2
votes
2 answers

How to detect what control triggers BeforeUpdate event in Access 2007

I have an audit trail that uses the BeforeUpdate event to track changes made on a subform using the following code: `Dim USR As String Dim TS As Date Dim Connection As ADODB.Connection Dim RecordSet As ADODB.RecordSet Dim Ctl As Control MsgBox…
110SidedHexagon
  • 555
  • 2
  • 14
  • 37
2
votes
1 answer

Grails: how to retrieve a persistent value for the collection?

I'm writing a Grails application and I need to retrieve a persistent value for the collection of my domain class objects. Let's consider we have got the following domain object: class UserGroup { SortedSet users static hasMany = [ users:…
Roman Reva
  • 55
  • 1
  • 7
1
vote
1 answer

Access - Using DLookup to prevent duplicate entries across two tables only prevents entry of top value

New here - fairly advanced excel user now trying to get to grips with Access. I'm building a database for schools data based on a linked table containing most of the schools information which is managed by another team (Contact Data Linked) and a…
Matt87
  • 25
  • 4
1
vote
0 answers

Oracle before update trigger - dynamically loop through columns with old and new value

I'm writing a database trigger for a history function. I had the hope that there is a chance to use one trigger for multiple tables. Also I don't want to check every single column by name. So I tried to create the trigger using dynamical SQL like…
SerCode
  • 11
  • 3
1
vote
2 answers

"No current record" after Cancel in combo_BeforeUpdate

I'm trying to prevent circular (or even cascading) references in my data, and it seems it's only working part of the time. In Access 2007, I have the following table: create table mfr ( mfr_id Autonumber, mfr_nm …
RolandTumble
  • 4,633
  • 3
  • 32
  • 37
1
vote
1 answer

Excel VBA: before, after or change event for combobox automatically updating another?

On my userform I have couple of comboboxes: Contractor, Product, Category, Unit. All of them are filled with data from MS SQL database (2012) and then the userform executes a stored procedure and inserts new records. I would like to build a dynamic…
kkris77
  • 117
  • 4
  • 15
1
vote
2 answers

Rails preventing update to certain values in a model

In my app I have note.rb with the schema shown below. What I am trying to do is restrict the ability to edit notes. Basically if the note has been created in the last 24 hours, you are allowed to update whatever you want. After 24 hours, all you can…
Zack
  • 2,377
  • 4
  • 25
  • 51
1
vote
2 answers

Grails save without changing attributes doesn't trigger beforeUpdate

I have a problem, I have a domain class called Cicle that calculates the value of some of its properties by making an average from a collection of other domain class called Measurement, so if any of its Measurements is updated then the Cicle should…
Ana Franco
  • 1,611
  • 3
  • 24
  • 43
1
2 3 4