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.
Related
Not sure if I could reliably reproduce this, but sometimes when I switch branches in development all requests start throwing an undefined method error inside of a helper. The method is present on both branches. I am using global helpers (helper :all).
To fix the issue, I go into the helper file and save any change. Usually I just add a new line to the end of it. After saving, it works fine. Seems like a caching issue.
Has anyone else seen this and resolved it? I am on Rails 4.2.1. As far as I know this only happens in development mode.
Since you are using Rails 4.2, spring has probably cached the code from the old branch. After switching to the new branch remember to run:
spring stop
Spring will restart itself the next time you run the server, tests, or other Rails commands.
I've searched fairly extensively for any advice and have yet to find it so, here goes:
My Rails project fails to automatically reload models in development. Reloading them currently requires a full server restart.
Previous instances of this issue have been related to non-activerecord files placed in the models directory, though this is not the case for me.
config.cache_classes is properly set to false in my development config file. Views and controllers reload without issue.
All of my rails components are version 3.2.11. I have tried disabling all of my development-specific gems to no avail. This is obviously not a productivity stopper, but it is quite an annoyance. Any help appreciated and I am happy to provide more information if it would help, though I am not using any exotic gems.
Thanks!
Some possibilities:
You are not really running on developement environment
You are changing a model within a namespace and didn't told rails to autoload the path
You are changing a file that is included in your class, not your class directly (or any of the many variants for this)
You are caching classes
Considerations:
Things might change according to the webserver you are using
How do you know it's not reloading?
I ask my question because I was having the exact same issue when I was trying to insert a debugger into what I thought was a piece of code that was being executed. I assumed the model wasn't being reloaded since it was not hitting the debugger but it was actually a call back that was redirecting me around the code with the debugger line in it.
So, it might be something other than your models not being reloaded.
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.
I'm having a bizarre issue where it seems as if Rails is skipping the run of my particular Action. I have two environments that I am running this in. One (development) works fine and runs the action. The other (staging) is not running the action.
The error is that Rails can't find a template in the views directories for my given action, which is only supposed to respond with JSON (no template). I've done logging in the action and it just simply isn't being run. Rails immediately fails saying that the view doesn't exist.
Just to cover my bases, I've verified that the code is indeed the same, that my routes file is exactly the same, and that my rails version (3.0.1) is exactly the same between the two env's. Any help would be excellent here.
Apparently this comes in the department of facepalm. One of our developers had committed a new controller with a different file name but the same controller class name as another. It must be that in development rails was loading the new controller first, and so the old controller would override it and the issue was hidden. In stage however, it seems that the new controller was loaded last, which cannibalized our controller class and method, screwing everything up.
I'd be interested to know if others have encountered this problem in rails. May need to patch the controller loading code to always use the same sort mechanism (seems like file name would be most natural).
Hey all- I'm working on some web flows for a Grails app we're building. I'm (slowly) getting the hang of the webflows themselves, but progress is severely limited due to the fact that changes to the webflow controller are not auto-reloading in Tomcat on save; basically, I need to bounce the app every time I make a change. As you can imagine, this is pretty painful. I think auto-reload was working a couple of days ago and then stopped, but I'm not sure.
Has anyone else experienced this? Any thoughts on how to make auto-reload work?
Thanks!
After much trial and error, here's what I found:
Situation: I have a controller with a single webflow. The first stage of the webflow uses a command object. (Grails 1.3.1)
1) Command and Webflow in same file; Command first: everything works, but the controller will not auto-reload on save.
2) Command and Webflow in same file; Webflow first: doesn't work- a serialization exception thrown when trying to render the page that references the command object.
3) Command and Webdlow in different files: everything works and controller auto-reloads.
For now I'll just keep everything in separate files. If anyone has insight into why this behavior is being exhibited, I'm all ears.