Sylvain
Sylvain

Reputation: 563

How to generate a controller with Ruby on Rails?

I installed Ruby 1.9.3 and Rails (rubygems-1.8.24) successfully on Windows 7.

Now I need to generate a 'controller home index' on command prompt. I created a project folder called 'rails-projects' and successfully created a project called 'quizzes-on-rails'.

At:

C:\rails-projects\quizzes-on-rails

I type:

ruby script/generate controller home index

And I get the following message:

ruby: No such file or directory -- script/generate <LoadError>

I edited PATH by including C:\rails-projects\quizzes-on-rails

Any idea what is wrong?

Upvotes: 2

Views: 8098

Answers (2)

Stoic
Stoic

Reputation: 10754

You can use:

rails g controller <ControllerName> [valid actions]

e.g.:

rails g controller Posts index show destroy

Upvotes: 1

bjhaid
bjhaid

Reputation: 9782

Start cmd prompt with rails or open the rails command prompt and run:

rails g controller Foo home index

Upvotes: 5

Related Questions