15

I installed ruby on rails, postgres. I installed all required gem files, I created a project as http://guides.rubyonrails.org/getting_started.html wants

I added below code in config/routes.rb

Blog::Application.routes.draw do
  resources :posts
  root to: "welcome#index"
end

I am trying to run rake routes command.

But i get

rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)

I checked internet.. Everybody says "i need to run it under exact project folder". But i need to say, I tried almost 20 different folders on my Windows 7. (I am getting crazy)

I don't exactly know what is necessary for you experts, but :

I use :

Windows 7 Ultimate (64bit) Ruby200-x64 rake-10.1.0

Thanks in advance..

Tim Tuckle
  • 1,372
  • 7
  • 21
  • 31
  • What is your present working directory? On Windows, you should be able to type `%~dp0` in the command prompt to find it. Does your pwd indeed correspond to your Rails application root? – zeantsoi Aug 26 '13 at 20:47
  • Yes, when i look at the directories that i ran the command, i can see app, bin, config, db,lib etc. folders – Tim Tuckle Aug 26 '13 at 20:59
  • Well, looking at what you posted (before you edited it and deleted it) there was no Rakefile. Look at the error message. You probably deleted it or never had it in the first place. – varatis Aug 26 '13 at 21:01
  • you said `i can see app, bin, config..` can you see `Rakefile`? if not, then there is your problem. – ddavison Aug 26 '13 at 21:08
  • oh guys!.. i created this project with rubyMine. And you are totally right!.. There is no Rakefile. i feel ashamed.. – Tim Tuckle Aug 26 '13 at 21:11
  • :D Gave you a little pointer in the answer if you needed a Rakefile. – ddavison Aug 26 '13 at 21:12

3 Answers3

31

I was having the same problem, and spent ages trying different commands, replacing rakefiles etc.

Turned out I was not in the app's root directory within the Command Prompt. :(

tonyedwardspz
  • 1,707
  • 2
  • 22
  • 45
19

Sounds like your Rakefile might be missing, or you might not be in the app's "root directory".

cd to your blog directory, and you should see,

$ ls
  app/
  bin/
  config/
  db/
  ...

If it doesn't exist already, create a new file named Rakefile and put this text in there.

#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)

Blog::Application.load_tasks
ddavison
  • 28,221
  • 15
  • 85
  • 110
  • Hi sircapsalot, the same thing happens to me each time I create a new app ($ rails new app..). No Rakefile is created. Is there a way to make sure that each time I create a new app and I '$ rake db:create', a Rakefile is automatically created? – Sylvain Jan 08 '14 at 17:34
  • @Sylvain: accordingly the doc (http://guides.rubyonrails.org/command_line.html#rails-new) it should create the rakefile. You may need to update rails – ddavison Jan 08 '14 at 17:40
  • it actually created a Rakefile but for some weird reasons it didnt see. Its after I created one (.txt) that it worked – Sylvain Jan 08 '14 at 17:52
1

I don't know why but this worked for me. worth a try

heroku rake db:migrate 

Found it on this discussion

Community
  • 1
  • 1
daniel_fahy
  • 83
  • 1
  • 7