how can I group my call backs in Rails - callback

I have many callbacks and I want to simplify or clean up the code.
Example:
after_create :email_admin
after_create :update_author_resource_count
after_create :get_resource_score
How can I write this like:
after_create :email_admin, :update_author_resource_count, :get_resource_score
Thanks in advance

you can write this like
after_create :email_admin, :update_author_resource_count, :get_resource_score

Related

How to use authorization in lumen

I followed this docs.
https://lumen.laravel.com/docs/5.5/authorization
Actually I dont know where to define the Gate
in register() or in boot() function
After that also it say: Class 'App\Providers\Gate' not found
And what is the correct one in 3 of these?
Illuminate\Auth\Access\Gate
Illuminate\Support\Facades\Gate
Illuminate\Contracts\Auth\Access\Gate
For the 'Checking Abilities', the docs said :
if (Gate::allows('update-post', $post)) {
But I cannot use that in my route file.
The question here is how to use gate in route?
Please support me. I'm new with this.
Thanks.
you should use this Illuminate\Support\Facades\Gate
**remember** everything that you use trough `::` like Gate::allows or
Route::get or something like that is `Facade` so for import use the uri that
contains `Facade`
Here is good tutorial which explain how to use `Gate`, hope it can be usefull
https://laravel-news.com/authorization-gates
https://code.tutsplus.com/tutorials/gates-and-policies-in-laravel--cms-29780
https://www.grafikart.fr/tutoriels/laravel/gates-policies-867

How to stop ZoneRefresh mixins in tapestry

I'm using the tapestry ZoneRefresh mixins to update zone periodically.
<t:zone t:id="zoneInf" t:mixins="zonerefresh" t:period="4" t:update="show">
<t:if test="ready">
success & How to stop refreshing
<p:else>
Loading...
</p:else>
</t:if>
</t:zone>
My question is: How to stop the refresh? Is this possible?
It sounds like you might have to write your own mixin. But it is very little code. Take a look at http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/periodicupdatemixin and http://tapestry5-jquery.com/mixins/docszonerefresh

How significant is the order with jQuery's trigger-method?

I want to provide a way to use an on-event handler from the outside of a plugin. Problem is, that the trigger will not fired if I provide them in wrong order.
For example, this works:
$(window).on('foo:bar', function(){
alert(true);
});
$(window).trigger('foo:bar');
...this, however does not:
$(window).trigger('foo:bar');
$(window).on('foo:bar', function(){
alert(true);
});
Any ideas how the second approach can work?
Update
Here it works: http://www.benplum.com/projects/rubberband/
You cannot. You want to eat cake before baking it.
UPD: You're misinterpreting the code at http://www.benplum.com/projects/rubberband/
Here is a jsfiddle with proof that it doesn't work like you're thinking: jsfiddle.net/zerkms/z5Mya/
Note about code: I've forked the library and added trivial console.log here: https://github.com/zerkms/Rubberband/blob/master/jquery.bp.rubberband.js#L77

How to use the function in springboard server?

I want to use the function "Reboot()" in the app with the springboardserver.framework,But when i add the private framework and the headers of springboardserver, the error will appear.
the reboot() is in the springboardserver.framework,the info about the springboardserver.framework function.
http://iphonedevwiki.net/index.php/SpringBoard.app/MIG_subsystem
I want to know how to use the function like this.Thank you for your help.
there is a function called SBReboot() (not sure about the function arguments) in SpringBoardServices.framework

Get object in i18n form

Inside embedded i18n form i need to get object.
In this example i got ArtistImageTranslation object, but i need ArtistImage.
Can somebody help me, how to get this?
class ArtistImageTranslationForm extends BaseArtistImageTranslationForm
{
public function configure()
{
$this->getObject();
....
}
}
Have you tried the following?
$artistimage = $this->getObject()->getArtistImage();
I spent half of day today on the same problem and looks like I finally found something ;)
First, if you need to access the fields which are in the "Translation" part of the table you can access them directly from the Object contained in the form. Just access the properties without using the getter (I know it's not the nice way but it works). So you can use something like:
$this->getObject()->id;
$this->getObject()->translated_name;
etc.
If you really need the original object you can access it like this:
$this->getObject()->getTable()->getRelation('ArtistImage')
->fetchRelatedFor($this->getObject());
Hope this helps.
Try :
$artistimage = $this->getObject()->artistImage;
or
$artistimage = $this->getObject()->artist_image;