Undefined property error while trying to create a new resource - laravel-nova

I get the Undefined property App\Plan::$bandwidth error when I try to create a new Resource or save the edited value.
However, values are listed fine for the same field during view/edit.
Here is the field definition:
Number::make('Bandwidth', 'bandwidth')->min(0),

The model had a method with the same name. Works fine after the renaming the method. I wonder if this is a bug.

Related

Puzzling validation error after upgrading from Grails 2.2.5 to 4.0.11

A method which was working for a long time in Grails 2.2.5 has broken after moving to 4.0.11 with a validation error on saving, and the error is a puzzle to me. I have a domain class 'Decline' which has one of its properties 'user', which is of domain class user. As part of the save process I assign the currently logged in user to this property:
Decline decline = new Decline()
decline.policy = policy
decline.declineTime = new Date()
decline.field = field
decline.cause = reason
decline.user = User.getUser()
decline.save(flush:true)
This was working fine in 2.2.5 but now I get the following validation error:
Field error in object 'myapp.pei.Decline' on field 'user.userType': rejected value [DIRECT_CLIENT]; codes [myapp.User.userType.nullable.error.myapp.pei.Decline.user.userType,myapp.User.userType.nullable.error.user.userType,myapp.User.userType.nullable.error.userType,myapp.User.userType.nullable.error.myapp.UserType,myapp.User.userType.nullable.error,user.userType.nullable.error.myapp.pei.Decline.user.userType,user.userType.nullable.error.user.userType,user.userType.nullable.error.userType,user.userType.nullable.error.myapp.UserType,user.userType.nullable.error,myapp.User.userType.nullable.myapp.pei.Decline.user.userType,myapp.User.userType.nullable.user.userType,myapp.User.userType.nullable.userType,myapp.User.userType.nullable.myapp.UserType,myapp.User.userType.nullable,user.userType.nullable.myapp.pei.Decline.user.userType,user.userType.nullable.user.userType,user.userType.nullable.userType,user.userType.nullable.myapp.UserType,user.userType.nullable,nullable.myapp.pei.Decline.user.userType,nullable.user.userType,nullable.userType,nullable.myapp.UserType,nullable]; arguments [userType,class myapp.User]; default message [Property [{0}] of class [{1}] cannot be null]
There are two things which are puzzling about this. Firstly, and more importantly, this appears to be an error saving the User object. But why is it even trying to save the User object? I have assigned an existing User object which it should be using. Secondly, the specific error is 'rejected value [DIRECT_CLIENT]' for field 'user.userType', but the error message is that this field cannot be null. So it's rejecting a value but telling me it cannot be null! The value, incidentally, is of a UserType enum defined thus:
public enum UserType {
ADMIN_USER,ADMIN_OWNER_USER,SUPER_USER,BROKER,DIRECT_CLIENT
}
I wonder what change from version 2.2.5 to 4 (or maybe 3) could have caused this?
It seems there was some change in behaviour of deepValidate between Grails 2.x and 4.x which is causing this, although I don't see why validation of the associated User object should be failing when it can actually be saved OK separately. But what got me past this issue was to set the following in the mapping block for Decline:
user cascadeValidate: 'none'
This ensures that when the Decline object is saved it does not attempt to validate the User as well.

Microsoft Graph fails when updating orderHint for a Planner bucket

I'm trying to update a Planner bucket's order. To do that, I set the orderHint value of that bucket to be <prevBucketOrderHint> <nextBucketOrderHint>!. This is the only change I make to the bucket object, however, when I try to save the changes, I get the following error:
Validation for field 'PlanId', on entity 'Bucket' has failed: This field is read only and cannot be changed
However, I'm not accessing nor modifying value of PlanId and therefore I don't understand why I get this error.
Below you can find the code I use to achieve my task (note that this is a C# code using the SDK and variable gc is a valid instance of Microsoft.Graph.GraphServiceClient):
theBucket.OrderHint = string.Format("{0} {1}!", previousBucket.OrderHint, nextBucket.OrderHint);
var etag = theBucket.GetEtag();
var result = gc.Planner.Buckets[bucketId].Request().Header("If-Match", etag).UpdateAsync(theBucket).Result;
Do you see any mistake in my approach or, alternatively, do you have any suggestions on how to change the order of buckets in a Planner plan?
Thanks
I'm guessing that you got theBucket object as the result of another call. The API endpoint expects a patch object that only contains the properties you want to update. You are sending the existing object as the patch object. The existing object theBucket has the planId set which is read-only at the service.
Fix it by creating a new PlannerBucket and only set the OrderHint property on it. Use the new PlannerBucket in the UpdateAsync method.

Can't add session variable - ActiveModel::MissingAttributeError

I am not very confident with Rails but have recently started adding custom session variables in order to store some data such as id's. I am trying to set a call id to a recently created value but keep getting an error.
Code:
callid = Call.createCall(sessionid,tp_cd)
session[:callid] = callid
This exact same thing works in other actions in the same controller, but here I get:
ActiveModel::MissingAttributeError (can't write unknown attribute `callid`)
I am simply calling this action with a POST call in order to manipulate some data and set this session variable to be used later. There must be something fundamental that I am missing about how session variables work. Is there anything obvious that could cause this error?
It gives an error because Rails looks for a model called Session, not the session object that is part of the request cycle.
You can get the session like this
request.session[:callid] = callid
In rails, creating a new record on the model name is just create method.
callid = Call.createCall(sessionid,tp_cd)
so it should be like this:
callid= call.create(params)
in params you need to define it like this: column name : your variable/value. So what columns are in your Call model? if you have session_id column, it will be like this:
callid= call.create(session_id: value_given )

How to get Entity Name in coredata

I have first project that dealing with coreData. I followed this tutorial. Everything was fine until I created new project with new core data models that has same fields and same structure to have deeper understand. However, I couldn't figure out where the variable self.entityName in class SDDateTableViewController.m got assigned value. Because the variable self.entityName in my new project is getting nil in method -(void)loadRecordsFromCoreData in SDDateTableViewController.m class.
Note: I did try copy every single line of code to my project, but the variable self.entityName is still nil
Please help me explain this issue.
It is define in the Storyboard on the SDDateTableViewController scene on "User defined runtime attributes".

Rails: How to use the find method on an arbitrary index

I have created a model that has a string as a unique identifier.
I created a migration to add an index on that string and set it to be unique.
How can i access a database entry by just passing its unique identifier string to the find method, for example
#object = Object.find(params[:unique_id])
At the moment, all i get is an ActiveRecord::RecordNotFound exception...
Couldn't find Object with id=abc
...when i try to access Object.find('abc')
The where method is no alternative as this gives me back a relation.
Object.find(:unique_id) searches on the column 'object_id'; If you want to search on an other column, use Object.find_by_[column_name]!(:unique_id). This will raise an exception if the record can't be found, as would do the find method.

Resources