How do I remove DbdocController? - grails

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.

Related

How to completely delete ruby on rails project from computer, heroku, and github

How do I completely delete a ruby on rails project from my computer, heroku, and github. I know the obvious, delete the project file, delete the github repo, and delete the heroku app, but are there any smaller steps i need to do. I just wanna make sure that if i happen to make a new project with the same name as a project i deleted, there wouldnt be a conflict.
You might also want to delete the database (the local version of it, on your computer). That's the only other thing.
If you used RVM or the like, it's also a good idea to delete the gemset or any gems installed specifically for your project. See http://rvm.io/gemsets/deleting. When I first started with RVM I created gem sets for everything - and always forgot to delete them when I deleted the project.

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.

Rails won't create new project because it thinks it's inside of one

I'm trying to create a new Rails project as I work through the book Agile Web Development with Rails. I installed Aptana Studio 3 and created one project successfully in its default workspace. I then decided I'd rather have it in another folder, so I deleted that one and tried to create a new one to a different path. That's when I got the error:
Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first. Type 'rails' for help.
I then navigated to the directory in a command prompt to confirm that it was empty. Using "rails new TestApp" gives the same error. I went up a level and created a new directory (to be the parent directory of the app) and received the same message there. I was able to create multiple projects in C:\tmp, but it won't let me create any under C:\Users\Account\Development. I have hidden files set to show, but is there something I should look for that would make rails think my Development folder is a project?
I'm in Windows 7 using ruby 1.9.3p125 and rails 3.2.3.
You have probably created a rails application is a parent folder of the folder you're trying to make one in now. I think rails looks for Gemfile (I could be wrong there) when it tries to access if the folder is a rails app. Take a look into your parent categories and search for that. Chances are you'll find the other associated pieces with it (app/, vendor/, etc...).
I think this may help you “Can't initialize a new Rails application within the directory of another, please Type 'rails' for help.”, I prefer that you search for similar kind of question over here before create a new question.
You already have the Rails app in the parent folder. You should uninstall the application from there. Remove all the Rails files from this folder.
If the rails app already exists on the parent directory, this error may occur. Go to the parent directory, and delete all the rails files/folders including Gemfile. Go to /Users/{your_comp_name}/ and see if you have rails files/ folders. If you do, remove those, and start your rails app again. This is kind of painful, but you may have to backtrack.
What worked for me was deleting all files and folders(~/app, ~/bin, ~/config, ~/Gemfile, ~/Gemfile.lock) generated by rails.
After removing the rails folder from binary folder, it worked:
cd /bin
sudo rm -rf /bin/rails

How do I either "unrm" in git repository or move files from one repository to another

I have a large rails project currently using rails 2.3.11 and I want to migrate it up to rails 3. I had an idea that I'd like to try but I need some git help.
What I want to do is start from a fresh new rails 3 app. One idea is to get in my current rails project directory and delete everything. Then do a commit so the tree is empty. Then create a new rails 3 project. This way I am starting fresh so everything will be current.
Then as I add the old controllers, etc back into the project, I want to "unrm" them. Git knows the history of the files and I'd like to keep that history.
Another alternative would be to start a fresh rails 3 app and then somehow transport files from the old git repository to the new git repository but I'd like to keep the history of the file.
This is a half baked idea but it seems a more viable approach to moving this particular project is to essentially start over fresh and then move things from the old project into the new project. But when I move things from old to new, I'd like to keep the history of each particular file.
Can anyone suggest a method of doing what I've just outlined?
First: check out this to automatically find some of the things that need to be upgraded: https://github.com/rails/rails_upgrade
To answer your question: You can upgrade your rails gem and then run rails new . to generate a new rails 3 app on top of your rails 2 app. It will clobber a few of your important files, but you can use git diff to figure out what was in them and copy the important things into the new file. Finally, there's a few things you might need to manually delete (like all of the files in the script/ folder except for rails). "Generating" a new rails 3 app on top of your existing app seems to be the recommended practice, and worked well for me when I upgraded a rather large and old app.

How to version control a rails plugin and the testing app together

I'm in the process of creating my first rails plugin and am finding managing version control of the plugin and testing app rather annoying.
Here's my problem:
To actually test my plugin in action I need to run it within a test application (which is basically just a scaffold app where I install the plugin)
When I'm making changes to the plugin, it's convenient for me to change it within the test application so i can immediately see the changes come through. However, when I want to commit and push my changes back to github I end up copying all the files out of the test app back into my "naked plugin" folder and doing my commits.
Is there a better way to manage this without copying files back and forth? I'm interested to hear from other plugin developers if possible on how you manage this situation.
One potential solution I've conceived of is to have another git repository within the vendor/plugins/myplugin directory (which will have the remote repo of github). Im not sure if this is best though (and so far I haven't been very successful in making it work...)
I recommend to use git submodules, check a detailed description.
I create a soft link in the vendor/plugin directory to point to the plugin source code.
If you are on Windows you can use the junction tool to create a softlink.
E.g:
c:\test_app
vendor
plugin
foo_plugin -> points to c:\foo_plugin
c:\foo_plugin
lib
Submodules are going work best I think. What I don't like about developing plugins is that you're always starting/stopping the script/server. Without knowing what kind of plugin you're building, I'll just assume that you're building an abstracted class of some kind.
I personally think the best way to go is to develop the class in the lib directory of your rails app. Once you get it about 99% done, then move the class into the lib directory of your plugin. Then commit the changes to the plugin repo.
If you're willing to package your final plugin as a gem, then there is a much easier way. In your basic scaffold app, inside your Gemfile you can point to a local path:
gem 'foo', :path => "../foo"
This way your scaffold app and engine/plugin are in two separate directories; two completely unrelated git repos. You don't even have to start & stop your scaffold web server when you make changes to the plugin (at least in rails 3).
I just wrote up a tutorial for how I created my first rails engine and I extracted the foundation into a good starting point for other engine builders:
http://keithschacht.com/creating-a-rails-3-engine-plugin-gem
As an end user of a plugin, I think it's much easier if it's packaged as a gem. Not only is more functionality possible with a gem, developers can install it once and use it in many apps, dependencies can be easily handled, upgrades are as simple as changing a version number, and you don't have to store the entire plugin in your main app's repo.

Resources