Error: Invalid target model for scope - loopbackjs

Hello loopback cracks,
I have the following problem: a model inherits from the built-in user model. When I run the application 'normally', all is well. When trying to do it in a mocha setup, I get the following error:
Error: Invalid target model for scope `Customer.prototype.accessTokens`
I can see that the Customer class has most accessors up, but for some reason it seems that accessTokens is not among them. I've been baking my noodle over this all morning. Can someone tell me what exactly this error indicates?

Related

Why is an unsaved parent class instance causing a NOT NULL constraint error when saving the child instance?

I'm following a tutorial of Pretty printed on youtube. During the tutorial he tries to instantiate a child model instance with a unsaved parent model instance called Language. But when he runs the code he gets an IntegrityError: NOT NULL constraint failed: example_framework.language_id
The narrator then explains that this is because he didn't call save() on the parent instance first leaving it without a primary key. This is the code form the tutorial, and heres the youtube part where he encounters the error: https://youtu.be/2KqhBkMv7aM?t=440
java = Language(name='Java')
spring = Framework(name='Spring', language=java)
java.save()
spring.save()
I don't understand why this gives an error though. Doesn't spring reference the same object that is referenced by the java variable? So if save() is called on java, shouldn't the Framework object referenced by the spring variable immediately have a primary key?

How to access my custom model located in catalog from system cart library in opencart 2.3

I am adding this code via modification into system cart library to access my custom model located in catalog/model/extension/folder_name/file_name:
public function __construct($registry) {
global $loader;
$loader->model('extension/folder_name/file_name');
$this->model = $registry->get('model_extension_folder_name_file_name');
}
But it says:
Fatal error: Uncaught Error: Call to a member function model() on null
in opencart 2.3.0.2
While this code is fine when I work on opencart 2.2.0.0.
Please help...
you got the idea right, just a syntax error.
In OpenCart in a controller file the loader is accessed via $this->load->model()
But in system/library/cart/cart.php your code should look like this
public function __construct($registry) {
$registry->get('load')->model('extension/folder_name/file_name');
$this->model = $registry->get('model_extension_folder_name_file_name');
}
This is because you are accessing directly in system/library/cart/cart.php, where you have access to the $registry from the construct but no __get() and __set() functions like the controllers and models have.
The cool thing is, the $this->load->model method actually checks where the cart is being called (is it from catalog folder or admin folder) and loads accordingly.
You can be safe to load a model in cart.php because it is only called in catalog folder, but be careful adding such code to system/library/request.php which is loaded both in catalog and admin. this will creat errors.

Importing caffe's PriorBox into TensorRT

We have a Caffe model that contains:
layer {
name: "foo"
type: "PriorBox"
prior_box_param { # ERROR HERE
# whatever
}
# etc
}
Now, following the code in sampleMNIST I try to import my model into TensorRT but get an error:
Error parsing text-format ditcaffe.NetParameter: 1000:19 ("ERROR HERE" location):
Message type "ditcaffe.LayerParameter" has no field named "prior_box_param".
Searching around, this is a known issue and there is even a TensorRT class nvinfer1::plugin::PriorBoxParameters that suggests it should be able to handle this layer, but there is little or documentation on how to proceed. I read one suggestion about splitting the model, but there are four instances of this node in my model, and more importantly, there is no information about what code should be in a custom node.
How should I handle this with minimal impact on the existing model that has been designed and trained by a third-party, so I cannot drastically alter either the model or the weights.

Ember.js 2.x: Handling "Could not find component..." error thrown by component helper

I have need in my Ember.js app to render a different component based on some piece of data. I've set this up via the component helper, like so:
<article class='awesome-article'>
{{component article-type}}
</article>
This works all fine and well, though naturally, if the article-type attribute doesn't match the name of any component in the application (which may happen due to fat-fingering), it gives us a nice, explicit error message:
Uncaught Error: Assertion Failed: HTMLBars error: Could not find component named "nonexistent-component" (no component or template with that name was found)
This is also great, but now I've got a smaller problem: I'd like to gracefully handle this error in the application, but I can't seem to figure out how to either catch or prevent this error. I've tried adding an error action to the parent component, but it skips right past it.
How can I go about handling this? This is probably one of those "missing something obvious" things, but my Google-fu has failed me this time.
You could create a handlebars helper that looks up if the component is registered in the container and based on this information you can display it or display some placeholder component.
If you are on at least Ember 2.3 you can use the public API they added: http://emberjs.com/api/classes/RegistryProxyMixin.html#method_hasRegistration

Redmine_RE plugin is not saving the data

i am using the Redmine.3.1.0.Then i have installed redmine_re plugin.But when i try to save the requirement using the Redmine_re plugin i am getting the following error
NameError (undefined local variable or method `connection' for #<ReArtifactRelationship:0x800ddb0>):
lib/plugins/acts_as_list/lib/active_record/acts/list.rb:220:in `bottom_item'
lib/plugins/acts_as_list/lib/active_record/acts/list.rb:214:in `bottom_position_in_list'
lib/plugins/acts_as_list/lib/active_record/acts/list.rb:205:in `add_to_list_bottom'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'
pls suggest how to resolve this error
#ste26054
I did not develop this plugin, but I think the support for redmine 3.1.0 is only partial at the moment. (And you may get other errors even after fixing this).
I believe you are getting an error because of this: Deprecate #connection in favour of accessing it via the class
And your error is related to this file:
In this method:
def scope_condition()
"#{connection.quote_column_name("source_id")} = #{quote_value(self.source_id)}
AND
#{connection.quote_column_name("relation_type")} = #{quote_value(self.relation_type)}"
end
Try to add self.class. in front of connection
You may have to repeat this for other files in the code.
If your changes are working, I would suggest you to submit a pull request on their plugin github page :)