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 the plugin | |
| ./script/generate plugin flash_helper | |
| # init.rb | |
| require File.dirname(__FILE__) + '/lib/flash_helper' | |
| ActionView::Base.send(:include, FlashHelper) | |
| # flash_helper.rb | |
| module FlashHelper | |
| def display_flash(flash) |
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
| 1.- rails jukebox -d mysql | |
| 2.- cd jukebox | |
| 3.- vi config/database.yml | |
| 4.- rake db:create:all | |
| 5.- ruby script/generate scaffold Artist name:string permalink:string albums_count:integer | |
| 6.- ruby script/generate scaffold Album artist:references title:string permalink:string | |
| 7.- Edit your db/migrate 001_create_artists migration file to initialize the counter cache for artists_count and add the index for the permalink column. | |
| def self.up | |
| create_table :artists do |t| |
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 c = Transaction.createCriteria() | |
| def cnt = c.get { | |
| projections { | |
| sum("amount") | |
| } | |
| eq("status", k) | |
| eq("transactionType", transactionType) | |
| ge("dateTimeProcessed", cal1.getTime()) | |
| le("dateTimeProcessed", cal2.getTime()) | |
| } |
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 c = Transaction.createCriteria() | |
| def cnt = c.get { | |
| projections { | |
| sum("amount") | |
| } | |
| and { | |
| eq("status", k) | |
| eq("transactionType", transactionType) | |
| ge("dateTimeProcessed", cal1.getTime()) | |
| le("dateTimeProcessed", cal2.getTime()) |
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
| class Book { | |
| def grailsApplication | |
| String title | |
| Float cost | |
| static constraints = { | |
| title(blank: false) | |
| cost(blank: false) |
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
| class CommonTagLib { | |
| static namespace = 'berry' | |
| def formatXML = { attrs, body -> | |
| String rawXML = body().toString() | |
| try { | |
| def slurpedXML = new XmlSlurper().parseText(rawXML) | |
| def writer = new StringWriter() | |
| new XmlNodePrinter(new PrintWriter(writer)).print(slurpedXML) |
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 berry = grailsApplication.mainContext.getBean('CommonTagLib') | |
| return berry.formatXML("....") |
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
| <html> | |
| <head> | |
| <meta name="layout" content="admintasia"/> | |
| <meta name="pageHeader" content="This is a test" /> | |
| <meta name="pageSubHeader" content="blah blah blah" /> | |
| </head> | |
| <body> | |
| ... |
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
| <h2><g:pageProperty name="meta.pageHeader" default="MISSING PAGE HEADER" /></h2> | |
| <h4><g:pageProperty name="meta.pageSubHeader" default="" /></h4> |
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
| package berry | |
| import org.springframework.web.multipart.MultipartFile | |
| import org.codehaus.groovy.grails.web.context.ServletContextHolder | |
| class FileUploadService { | |
| boolean transactional = true | |
| def String uploadFile(MultipartFile file, String name, String destinationDirectory) { |