previous_changes in rails after_update for an hash field not working - ruby-on-rails-3

I am using rails 3 and for one of the use cases, I need to detect a change in a hash field. I am making changes to the f attribute which is a hash inside the hash attribute. Something like this: Table.field = {:e=> 'hello', :f=> {"new_field"=>"In progress"}} So when I make changes to new_field it's not reflecting in previous_changes method or changes method in after_update callback. I need to trigger a few events based on this. However, it always gives {}. I tried to replace the whole field with a different value and that change is detected. Is there any other method that we can use to detect hash changes?

Related

How can I change the mode column filter works in vue CSmartTable?

I am trying to change filters because I want to ignore accents and it must search by full words.
I don't know how to change the behaviour, override functions, nor create a custom filter.
I prefer not to use new inputs but use inputs already exist created by the component and change their behaviour.

Azure DevOps Access Custom Field From Script

I have a required custom field on any ticket created (Bug, Tasks, PBI).
I have a pipeline that creates tickets automatically, but the values that are used to create these tickets doesn't have a value for my custom field. I want to set this custom field by adding an entry to the pipeline variables, but I don't know the variable name of the custom field.
How can I find the variable name of the custom field so I can access it?
I found out how to determine your custom variable name.
ADO has a bunch of APIs. The following will give you all the details of a specific work type. For my case I needed the "bug" work type.
/*
Api to display work type fields in JSON format
Replace {} with correct values
*/
https://dev.azure.com/{orginization}/{project}/_apis/wit/workitemtypes/{type}/fields?api-version=6.0
The resulting JSON will give you a whole list of variables. Here is what the System Variable and a Custom Variable look like.
The referenceName is the variable name you would use in your scripts, etc.
TL;DR -
Take your field name and remove all spacing and then put Custom. in front of it.
Custom.FieldNameWithNoSpace

Can I use filters in Intellij structural search to reference variable counts?

I am trying to create a custom inspection in IntelliJ using structural search. The idea is to find all methods that have one or more parameters, of which at least one is not annotated. Bonus: Only hit non-primitive types of parameters.
So far, I have created the following Search Template:
$MethodType$ $Method$(#$ParamAnnotation$ $ParameterType$ $Parameter$);
using these filters and the search target "complete match":
$Parameters$: count[1,∞]
$ParamAnnotation$: count[0,0]
However, this only hits methods without any parameters annotated. I want it to also match methods where only some parameters have an annotation but others don't.
Is it possible to reference the count of one variable in the filter of another, e.g. by using script filters? If so, how?
You can do this by creating a Search Template like this:
$MethodType$ $Method$($TypeBefore$ $before$,
#$ParamAnnotation$ $ParameterType$ $Parameter$,
$TypeAfter$ $after$);
Filters:
$Parameters$: count=[1,1] // i.e. no filter
$ParamAnnotation$: count=[0,0]
$before$: count=[0,∞]
$after$: count=[0,∞]
This will find all method with at least one parameter without annotation.

Check if field is modified in mongoose's post hook for function findOneAndUpdate

In the controller I'm incrementing a field with findOneAndUpdate. The increment is not necessarily always executed, which depends on whether the condition for a update query has been met.
If the field has been incremented tho, an another model should updated as well. So, I was thinking to use:
schema.post('findOneAndUpdate', function(err) {
pseudo-code:
if (field is incremented)
anotherModel.update()
});
The problem is that I don't seem to be able to determine if the field has been modified.
Self reference (this) points to a funny object of considerable size, (unlike in e.g. middleware functions for 'save'), so I don't see much other options to determine if field is modified.
Any ideas?
The argument passed to the callback for findOneAndUpdate's post middleware is the matched document to be updated and not an error as common in the node callback pattern. Within the callback, this is the query object returned from the findOneAndUpdate.
schema.post('findOneAndUpdate', function(doc) {...});
Also note that if you want the updated document rather than original document that matches the query you must specify the new option in the query:
findOneAndUpdate(QUERY, UPDATE, {new: true});

How to use the data store to set a toolbar title in Sencha Touch

I am trying to set the toolbar item dynamically. So far I have a back button that resets the toolbar title to 'start' if the user chooses to go back.
But the following code won't work:
menuList.on('itemtap', function(dataView, index, item, e){
viewport.dockedItems.items[0].setTitle('{title}');
});
It tries to use a variable called 'title' out of my data store array. This works great for providing text to my Ext.List items. But the above code sets the toolbar title to the string '{title}' without even thinking of it being a variable.
Can you help me out?
List's use templates so items within curley braces get evaluated... you'll need to pass a reference to a variable without quotes. You haven't provided enough code for me to tell you where that information would be. If you already have a variable in scope called title that you put the data into then you can just reamove the '{ and }' ... otherwise you'll need to get the data you need from your store through some means, like Ext.StoreMgr or [appname].stores
Two things. 1) You will really want to get used to digging into the ST source code. In this case, if you look at the code for "setTitle", you will see that its argument is interpreted as straight HTML, not a template. So you can't use curly bracket syntax here. 2) Note that the type of the "item" argument to the event handler is an Element (i.e. ST's representation of the DOM object, not the selected datastore object. So that's not going to help you. However, the "index" arg gives you an easy way to get the appropriate object from the store. i.e.
[appname].stores.pages.getAt(index).title
I really don't know why, but it works if you put up to variables: One for the record and one for the value inside that record. There is a detailed explanation in the sencha.com-forum