Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby on Rails : rails generate controller does not work

I am new to ruby and rails and I am having a problem with generating controllers.

Some context :

$ rails -v
Rails 4.1.1

App is created correctly :

$ rails new test_app
      create
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
[...]
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
         run  bundle exec spring binstub --all
* bin/rake: spring inserted
* bin/rails: spring inserted

Server runs fine :

$ rails server
=> Booting WEBrick
=> Rails 4.1.1 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
[2014-06-07 11:12:20] INFO  WEBrick 1.3.1
[2014-06-07 11:12:20] INFO  ruby 1.9.3 (2014-02-24) [x86_64-cygwin]
[2014-06-07 11:12:20] INFO  WEBrick::HTTPServer#start: pid=3340 port=3000

I can browse the default page, but then when I try to go to the next step, it's failing :

$ rails generate controller welcome index

Nothing happens and the files are not generated. There is not output at all so I don't know where I should look to fix the issue.

I already tried creating a fresh new app and reinstalling rails, but this doesn't help.

like image 282
Silk Avatar asked Jun 07 '14 10:06

Silk


2 Answers

Try to run

spring stop

rails generate may not work because spring is already running.

like image 193
timberlake Avatar answered Oct 13 '22 06:10

timberlake


I had the same problem on my Windows machine while trying to run rails generate controller Users new.

First, make sure your spring is not running. Stop it with spring stop

If it did not help THEN:

  1. Go to your Gemfile and comment out next two lines : gem 'spring' and gem 'spring-watcher-listen', '~> 2.0.0'
  2. In your terminal, run: bundle update
like image 25
Olga Avatar answered Oct 13 '22 06:10

Olga