How to delete an app from a Rails project? - ruby-on-rails

Initially I made 2 apps (app_a and app_b) in a single project in Ruby. Now I want to delete one (say app_a). How should I do so? Is deleting the app folder sufficient?

You need to drop your related database and then delete the app directory
# from app directory
rake db:drop
cd .. && rm -rf app_a
Rails generator command creates a copy of the framework. The app directory id self contained. Deleting it is enough. If you are using sqlite as your database then you can skip first command.

Deleting the app folder will get rid of it. Be sure to clean up your routes file if needed as well as get rid of a database table if it was created.

Related

How to Delete Derived Data and Clean Project in Xcode 5 and later?

Is there a procedure I can follow that includes running a script in the terminal, to delete all the files under the derived data folder and reliably clean a project?
Sometimes, a project's assets don't always get updated to my simulator or device. It's mostly trial and error, and when I find that an old asset made its way into a test build, it's too late, not to mention embarrassing!
I've looked at this question, but it seems a little outdated:
How to Empty Caches and Clean All Targets Xcode 4
I also checked out this question, but I don't want to waste time in Organizer, if I don't absolutely need to: How to "Delete derived data" in Xcode6?
I've looked at other posts out there, but found nothing that solves the problem of reliably cleaning a project and saves time with a script.
It's basically a two-or-three-step process, which cleans the project of all cached assets.
Of course, if anyone uses this technique, and a project still does not show updated assets, then please add an answer! It’s definitely possible that someone out there has encountered situations that require a step that I’m not including.
Clean your project with Shift-Cmd-K
Delete derived data by calling a shell script (details below), defined in your bash profile
Uninstall the App from the Simulator or device.
For certain types of assets, you may also have to reset the Simulator (under the iOS Simulator menu)
To call the shell script below, simply enter enter the function name (in this case 'ddd') into your terminal, assuming it's in your bash profile. Once you've saved your bash profile, don't forget to update your terminal's environment if you kept it open, with the source command:
source ~/.bash_profile
ddd() {
#Save the starting dir
startingDir=$PWD
#Go to the derivedData
cd ~/Library/Developer/Xcode/DerivedData
#Sometimes, 1 file remains, so loop until no files remain
numRemainingFiles=1
while [ $numRemainingFiles -gt 0 ]; do
#Delete the files, recursively
rm -rf *
#Update file count
numRemainingFiles=`ls | wc -l`
done
echo Done
#Go back to starting dir
cd $startingDir
}
I hope that helps, happy coding!
Another way to delete derived data in Xcode is just by deleting the Derived Data folder.
Here is a visual tutorial of how you can do that easily without using command line: https://www.youtube.com/watch?v=ueEMGXKDBAc

I cannot get git to ignore my tmp folder of my Ruby on Rails project

So I tried everything
but to no avail
I keep getting the following error
"fatal: cannot use tmp/ as an exclude file"
I have even tried using /tmp and tmp/* but none of these two work either .
Finally I deleted the tmp folder in frustration and i found that git now works perfectly
SO I have two questions.
The obvious one being . How do I get this to work?
Is it possible for me to run my ruby on rails applications without the tmp folder?
The obvious one being . How do I get this to work?
Add /tmp to your .gitignore at the root of your Rails app. Make sure you add and commit this .gitignore before committing /tmp — you'd have to git rm it to make it disappear from the repository again.
Is it possible for me to run my ruby on rails applications without the tmp folder?
No. Why would you? Rails needs to be able to write files there in order to work properly. You can only symlink it somewhere else, but that won't really solve the issue if the files are included in your repository. See also: Rails3: Change location of temp (tmp) directory
It may have to do with the way git works with cached files that the folder may still show up after including it in the .gitignore file.
Try git rm . -r --cached in the command line to clear out the cached files.

Creating a Rails app in workspace directory of Cloud9 IDE

When I run rails new . hoping to create a new Rails app in my workspace directory, rails says:
Invalid application name 567101. Please give a name that does not start with numbers.
How do I get around this? I could just create it within the top level directory, but that seems inelegant. When you create a workspace and select "Rails" for the type it sets up the app nicely in the right place, but I want to set up a Rails 4 app, so that's not an option.
I was just trying to figure this out myself. What I ended up doing is creating a symbolic link to the numbered directory named rails_app. I was then able to do a rails new and have it create the application.
First
cd ~/
Then
ln -s ./567101 ./rails_app
Then
rails new ./rails_app

Can't start a new rails app

When I try to start a new rails app, I get this notification:
"Can't initialize a new Rails application within the directory of another, please Type 'rails' for help."
I read that I may have to empty some directory because there may already be another rails app created. I'm not sure how to do this and start over.
cd ~
cd ProjectsDir # <= Wherever you save your projects
rails new project
cd project
rails generate ...
typing cd .. means going backwards in the directory you're in ...
for example, you're in this_directory, and it's on desktop ...
so, typing cd .. while in this_directory means that you're back on desktop directory now ...
as for the current directory that you're in, don't worry about it ...
just go backwards, and when outside of it, you can delete that directory as you wish, or leave it alone.
type "rails new name_of_app" to start a new rails project ...
and of course, type cd name_of_app to go into the directory of your new rails project.
let us know if you need further clarification ...
cd ../
rails new i_am_in_new_directory

Deleting folder containing file

I want to send the file file.txt from my Rails controller using send_file, and then delete the folder containing it.
send_file("#{Rails.root}/public/folder/file.txt")
system("rm -rf #{Rails.root}/public/folder")
When I tried this, file.txt was correctly sent, file.txt was correctly deleted, but somehow folder was not deleted.
How can I make it delete folder?
Try to delete the folder directly with the native ruby method instead of a system command:
require 'fileutils'
FileUtils.remove_dir "#{Rails.root}/public/folder", true
http://www.ruby-doc.org/stdlib-1.9.3/libdoc/fileutils/rdoc/FileUtils.html#method-c-remove_dir

Resources