Logging SQL statements in Grails 3

You can enable logging of the SQL queries that Hibernate executes via the logSql property of your datasource config in either application.yml or application.groovy. Setting logSql to true enables logging to stdout. You will see output similar to the one below: Hibernate: create table book\_chapter\_page\_count (book\_id bigint not null, chapter\_page\_count\_integer integer) ENGINE=InnoDB Hibernate: alter table book\_chapter\_page\_count add constraint FK87brho4gbq6gbns18fnschhsx foreign key (book\_id) references book (id) The logged SQL can be formatted by setting formatSql to true.

Handling 404 errors with Vue Router

Using the asterisk (*) in the Vue Router object definitions allows you to match anything, you just have to be careful and place them at the end of your routes array so that precise paths are matched first. Therefore, to handle 404 errors, all you will have to do is match the catch all path to your 404 error component. The Vue Router object would be defined like so: new Router({ routes: \[ { path: '/blog-post/:id' name: 'blogPost', component: BlogPost }, { // matches everything else path: '\*', name: 'notFound' component: NotFound } \] }) As you can see, it’s dead simple.

VeeValidate pretty field names error messages in

By default VeeValidate uses the name or data-vv-name attributes of the input element for the field in error messages. For the field below: <input name="startDate" v-validate="'required'" type="text"/> <span>{{ errors.first('startDate') }}</span> The error message when the start date is not specified would be: The startDate field is required, which is not exactly user friendly. Step forward the data-vv-as attribute. As the docs put it, it specifies a pretty name for the field.

Communicate between Vue.js instances

To communicate between two Vue instances you need to create an event hub/event bus. Since Vue instances implement an event emitter interface this can easily be achieved by declaring an empty Vue instance: let eventHub = new Vue() You can then $emit events from the first instance as follows: let appOne = new Vue({ methods: { onClick () { eventHub.$emit('button-clicked') } } }) And use the created hook in the other app to listen for the event:

Enabling inferred rules in VeeValidate 2.1.4

If upgrading to VeeValidate 2.1.4 you will find that any of your form validation making use of inferred rules will be broken. This is because the functionality is now disabled by default. To enable it again, you will need to set the validity flag to true when you install the plugin. This is shown below: Vue.use(VeeValidate, { validity: true }); Fortunately, as you can see there is not much needed to get inferred rules working again.

Making a field conditionally required with VeeValidate

There are instances when you are using VeeValidate for form validation and you want a field to be required only if a certain condition is met. This blog post will illustrate how to achieve that in two different ways. 1. Using a computed property You can make use of a computed properties to return a dynamic validation expression.<input name="email" v-validate="rules" />For the input element above the computed property rules would look something like this:computed: { rules () { let rulesExp = "email" return rulesExp += this.