rails generate model rails generate model ruby-on-rails ruby-on-rails

rails generate model


The code is okay but you are in the wrong directory. You must run these commands inside your rails project-directory.

The normal way to get there from scratch is:

$ rails new PROJECT_NAME$ cd PROJECT_NAME$ rails generate model ad \    name:string \     description:text \    price:decimal \    seller_id:integer \    email:string img_url:string


The error shows you either didn't create the rails project yet or you're not in the rails project directory.

Suppose if you're working on myapp project. You've to move to that project directory on your command line and then generate the model. Here are some steps you can refer.

Example: Assuming you didn't create the Rails app yet:

$> rails new myapp$> cd myapp

Now generate the model from your commandline.

$> rails generate model your_model_name 


You need to create new rails application first. Run

rails new mebaycd mebaybundle installrails generate model ...

And try to find Rails 3 tutorial, there are a lot of changes since 2.1 Guides (http://guides.rubyonrails.org/getting_started.html) are good start point.