Grails: Unable to generate views - grails

This is a very basic thing and I have no idea why am not able to do this. I am using Grails 2.3.5
I have a domain class com.trail.AuditTrail and I want it scaffolded views. So, here are the steps I followed:
ran grails create-controller com.trail.AuditTrail, this returned a message saying it generated:
grails-app/controller/trail/AuditTrailController
grails-app/views/auditTrail (just the folder!)
It also created AuditTrailControllerSpec.groovy.
Then I added the line static scaffold = true in the Controller.
Then ran generate-views to create the views, but nothing got created !
IMPORTANT: In fact grails says that there is no command called as generate-views. When I did grails help it didn't list generate-views. So, I thought may be 2.3.5 doesn't have the command and tried generate-all. This too failed. To my surprise, grails help didn't show up generate-all too !
Then I found this bug: https://jira.grails.org/browse/GRAILS-10530. So, I tried clean, refresh-dependencies, compile and then generate-all. But still the same problem.
I thought my local grails setup is messed up. So, asked my colleague. He too sees the same problems.
My problem is I am not able to create the default template GSPs out of the domain.

Scaffolding functionality was extracted from Grails core in 2.3, so you need to install scaffolding plugin for Grails 2.3.5 to be able to use generate-all, generate-views GANT scripts.
P.S. I suggest you to switch to Grails 2.3.6 or 2.3.7. For more details take a look at this article http://www.gopivotal.com/security/cve-2014-0053

for that right click on action then click on generate view

Related

Grails 3 does not have wrapper?

Does Grails 3.0.x no longer have the ability to create wrappers anymore?
The documentation doesn't seem to have the Grails wrapper section anymore.
Is there an alternative way which we can use the gradle wrapper to execute grails commands such as create-controller?
Does Grails 3.0.x no longer have the ability to create wrappers
anymore?
No.
Is there an alternative way which we can use the gradle wrapper to
execute grails commands such as create-controller?
Not for commands like create-controller, no.
We may re-introduce grailsw. File a feature request at https://github.com/grails/grails-core/issues if you would like to track that.
The Grails wrapper is back as of Grails 3.2.3:
http://docs.grails.org/3.2.x/guide/introduction.html#whatsNewGrailsWrapper
I have an app created with Grails 3.1.x, then upgraded to Grails 3.2.6, but the files such as 'grailsw' did not appear in my project root, and I'm not sure how to get them added via some command in the project.
When I create a new app using Grails 3.2.6, the new files are in the project root (grailsw, grailsw.bat, grails-wrapper.jar). I assume they can be copied over to an app like mine: a quick test of this worked for me.

Grails Data Base Migration - dbm-gorm-diff is not working

I am using Grails 2.3.5 with database migration plugin in new project for understand how it is working. But sometimes dbm-gorm-diff provide empty changelog file,even changes is there.
For example,
i have the person domain class with out any properties.
When initially creating change log, it will create 2 fields id and version in change log.
After that, added 2fields name,age into that person class. then did dbm-update and dbm-gorm-diff that give like following.
databaseChangeLog = {
}
Sometimes gives the changes. some times is not working. Please help me. Why it is working like that. Sorry for bad english.
Using the following tutorial works for me. Make sure you remove dbCreate from your DataSource.groovy. According to the tutorial the workflow is as follows:
Setup
Remove dbCreate from DataSource.groovy
Initially run grails dbm-generate-gorm-changelog changelog.groovy
Sync the changelog with your db by running grails dbm-changelog-sync
Changing domain
Change domain class
Run grails dbm-gorm-diff <your-filename>.groovy --add
Run grails dbm-changelog-sync
Hope this helps
I have spent some time searching for the answer to this same issue.
Caveat: I am using the Grails interactive shell to issue commands, including the dbm-* commands.
By brute force alone, I have come to the conclusion that the domain classes are not reliably reloading. To get consistent results (especially with the generation of new changeLog files), any time I modify a domain class, I stop and restart the Grails interactive shell before calling dbm-gorm-diff. I've tried issuing other commands like clean, compile, package and refresh-dependencies and they just aren't working, and the -reloading flag at the start up of the Grails interactive shell doesn't seem to make any difference either.
Restarting the Grails interactive shell, however, does seem to work reliably, thought it galls me to do so :)
Those who do not use the interactive shell should not be having this problem since the domain classes are loaded with every command call.
This blog has detailed step by step explanation, specially Migrating old databases section helped us in migrating successfully.

Grails without gorm

I'm trying to create a grails app that has no database/hibernate/gorm/datasource configuration. In Rails, I can create a new app with the '--skip-active-record' command which will let me create controllers/models/etc without any database concerns.
I'm needing this because my controller just makes a couple rest calls and returns a result so there's no need for the database.
Is this possible? I saw Can I configure Grails with no datasource? but it seems to not work with Grails 2.3. I get this message: "To remove a plugin, delete it from BuildConfig.groovy and/or application.properties."
Is this possible? Thanks
The uninstall-plugin and install-plugin commands were deprecated in 2.2 and removed in 2.3.
To remove a plugin, delete it from BuildConfig.groovy and/or application.properties.
So you can just remove the hibernate plugin entry from BuildConfig.groovy. You probably also need to remove the cache plugin, and you should remove the database-migration plugin since you won't need it.

Grails 2.0.1 controller action methods have stopped working

My project has always used grails 2.0.1 and my controllers define their actions as methods not closures. Previously these actions have always worked (i.e. the browser can render the correct gsp page first going through the action method in the controller).
Recently we've noticed that the bespoke actions no longer work, the browser reports a '404 resource not found'. We're still on grails 2.0.1, this is confirmed by 'loading grails 2.0.1' comments in every grails command that is run. Although there are some controller/domain/services changes, none of those changes should affect the use of action methods. From what I can tell, we've not downgrade the version of grails/groovy.
If I change the actions to be defined as closures, then it works fine. But I'm not happy with this as my solution as methods are the preferred way and it used to work.
I've tried the usual approach to grails weirdness: proper clean and rebuild, but no joy. Also, this is an issue in both eclipse and unix envs (project delivered as a war run by the grails command), so it must be something in the project files but I cannot spot anything that has changed.
Any suggestions what could have happened to my project and how to resolve?
I've finally tracked my problem down to an aspect I was using to monitor long running method calls. I had changed the pointcut to include 'within(com.mydomain.domain..*)' which is where my Controller class resides. This appeared to stop my bespoke links from working, not entiring sure why. I hadn't intended this, I just wanted my pointcut to include all domain class methods but I'm happy to sacrifice that in order to get controller method actions working again.
I've resolved this issue by amending my pointcut.

How do I remove DbdocController?

I've installed Grails 2.1.2 and created a project.
When I run my project, the default page lists the following under Available Controllers:
grails.plugin.databasemigration.DbdocController
Not wanting to have to deal with this controller (which apparently doesn't work by default), I decided to try and get rid of it. Of course, the first thing I find is that there is no such controller under my project's controllers directory.
Having read that this controller is related to the database-migration plugin, I promptly uninstall this plugin using the grails uninstall-plugin command. This is successful according to Grails, but the controller is still there. The next thing I tried was to delete this plugin from my project's plugins directory, but I find that there is no such directory in my project.
How would I get rid of this virtual controller?
If you don't need database migrations (this is unlikely) then you can uninstall the plugin by removing it from your BuildConfig.groovy. There's no other way to remove the controller. Note that it's disabled by default in prod, so there's no need to remove it.

Resources