This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Validation Errors and Rollback | |
A common use case is to rollback a transaction if there are validation errors. For example consider this service: | |
import grails.validation.ValidationException | |
class AuthorService { | |
void updateAge(id, int age) { | |
def author = Author.get(id) | |
author.age = age | |
if (!author.validate()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function() { | |
// Handler for .ready() called. | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-XX:MaxPermSize=512m -Xmx4096m |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Map generateAssignments(List<String> participants) { | |
def assignees = participants.clone() | |
Collections.shuffle(participants) | |
Collections.shuffle(assignees) | |
def assignments = [:] | |
participants.each { participant -> | |
def assignee = assignees.find{ it != participant} | |
assignments[assignee] = participant |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export JAVA_OPTS="-XX:MaxPermSize=512m" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE DATABASE dbname CHARACTER SET utf8 COLLATE utf8_general_ci; | |
or | |
CREATE DATABASE dbname CHARACTER SET utf8 COLLATE utf8_bin; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def countRows = db.firstRow("select count(*) as numberOfRows from languages") | |
assert 4 == countRows.numberOfRows |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A form with associated inputs | |
<g:form action="seed"> | |
<g:each in="${teams}" status="i" var="team"> | |
<input type="hidden" name="teams.${i}.id" value="${team.id}"> | |
<input type="text" size="2" name="teams.${i}.seed" value="${team.seed}"> | |
</g:each> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git push -u origin your_branch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def errorMessages = ex.errors.collect { g.message(error:it) } |
OlderNewer