before-save

Lock Cells after Data Entry

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-15 05:24:08
问题 I have a spreadsheet that is edited by multiple users. To prevent tampering with previous data the cells are locked once data has been entered and the file saved. I have a few small bugs in the code though: Even if the user has saved manually and then exits the application they are still prompted to save again. The cells should be locked after a save when the application is running and not just when it is exited. Previously I had this code in the before_save event but the cells were being

Android: Parse beforesave to database

≯℡__Kan透↙ 提交于 2020-01-03 04:47:09
问题 I am going to save records to Parse database. Saving to Parse: ParseObject database = null; database = new ParseObject("Record_db"); database.put("period_ref", current1_draw_ref_I); database.put("remark", "na"); database.put("publishing", "publishing"); database.saveInBackground(); Cloud Code: Parse.Cloud.beforeSave("check_duplicate", function(request, response) { var DB = Parse.Object.extend("Record_db"); var query = new Parse.Query(DB); query.equalTo("period_ref", request.object.get("period

Before_save = Change default value for many to many

喜夏-厌秋 提交于 2019-12-25 03:28:12
问题 Can someone help me figure out what code I should put in my change_default method? I would like to be able to do something like this... user = User.find(1) user.companies.first.default! or user.companies.find_by_company_id(2).default! My code: class Role < ActiveRecord::Base before_save :change_default belongs_to :user belongs_to :company def change_default #update default field for to false for current scope #Update current record default field to true #this is what I currently have, but it

How to query objects in the CloudCode beforeSave?

蹲街弑〆低调 提交于 2019-12-20 04:38:51
问题 I'm trying to compare a new object with the original using CloudCode beforeSave function. I need to compare a field sent in the update with the existing value. The problem is that I can't fetch the object correctly. When I run the query I always get the value from the sent object. UPDATE : I tried a different approach and could get the old register ( the one already saved in parse). But the new one, sent in the request, was overridden by the old one . WHAT?! Another issue is that, even

Force Save as XLSM While Maintaining File Structure

时光毁灭记忆、已成空白 提交于 2019-12-12 09:45:57
问题 So I am working with a XLTM file, and I want the user to make sure they save as XLSM. When they click "Save," this works fine, but I find when they click "Save As," the file is saved as "*.xlsm.xlsm". I am a little lost with how to make sure that the user saves as XLSM, while keeping the file name as "filename.xlsm" and not "filename.xlsm.xlsm". 'Action makes sure the user saves as XLSM file type. Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim FileNameVal As

Can't delete row from beforeSave method in CakePHP 2.4+

不问归期 提交于 2019-12-12 04:57:55
问题 I cant delete in my beforeSave() method in newer version of Cake but it works with earler libs (e.g. version 2.2) Does anyone know how get it working again without altering the Cake libs? Code: public function beforeSave($options = array()) { if(!empty($this->data['Attachment']['delete']) && (int) $this->data['Attachment']['delete'] === 1) { if($this->deleteFromDb((int) $this->data['Attachment']['id'])) { $this->data['Attachment'] = array(); return true; } else { return false; } } return true

CakePHP ignores beforeSave methods when saving HABTM join model

若如初见. 提交于 2019-12-11 11:35:21
问题 So I have three models: Coach: var $hasAndBelongsToMany = array("Tour") Tour: var $hasAndBelongsToMany = array("Coach") CoachesTour: var $belongsTo = array("Tour", "Coach") There is an HABTM association between Coach and Tour, and it should use the CoachesTour as the join model. I'm using scaffold. When modifying a Tour, if I add a new CoachesTour to it, the beforeSave method of CoachesTour isn't called. It seems as if the records of the join model are being inserted as SQL statements,

How to prevent updating a single attribute in Rails?

别说谁变了你拦得住时间么 提交于 2019-12-11 10:31:34
问题 When a form is submitted, how to prevent a single attribute from being updated in Rails? All other attributes should be updated. Is it before_save , attr_reader or some other way? If using before_save , how to access to the attributes hash? Rails 3.0.7 回答1: Check out attr_protected . Class YourModel << ActiveRecord::Base attr_protected :the_one_column, as: :update # ... end Now as part of a call to update_attributes , you'd specify the :update role, for example klass = YourModel.find(some_id)

Force Save as XLSM While Maintaining File Structure

倾然丶 夕夏残阳落幕 提交于 2019-12-05 12:44:57
So I am working with a XLTM file, and I want the user to make sure they save as XLSM. When they click "Save," this works fine, but I find when they click "Save As," the file is saved as "*.xlsm.xlsm". I am a little lost with how to make sure that the user saves as XLSM, while keeping the file name as "filename.xlsm" and not "filename.xlsm.xlsm". 'Action makes sure the user saves as XLSM file type. Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim FileNameVal As String If SaveAsUI Then FileNameVal = Application.GetSaveAsFilename(, "Excel Macro-Enabled Workbook (*

How to query objects in the CloudCode beforeSave?

痴心易碎 提交于 2019-12-02 05:15:16
I'm trying to compare a new object with the original using CloudCode beforeSave function. I need to compare a field sent in the update with the existing value. The problem is that I can't fetch the object correctly. When I run the query I always get the value from the sent object. UPDATE : I tried a different approach and could get the old register ( the one already saved in parse). But the new one, sent in the request, was overridden by the old one . WHAT?! Another issue is that, even thought the code sent a response.success() , the update wasn't saved. I believe that I'm missing something