Ruby on Rails , No Rakefile found error

2019-04-07 03:46发布

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..

3条回答
Juvenile、少年°
2楼-- · 2019-04-07 03:47

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
查看更多
唯我独甜
3楼-- · 2019-04-07 03:56

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

heroku rake db:migrate 

Found it on this discussion

查看更多
叼着烟拽天下
4楼-- · 2019-04-07 04:04

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. :(

查看更多
登录 后发表回答