I am trying to create a simple form in Rails 3. But facing this issue:

Showing /home/praveen/rails_projects/mebay/app/views/ads/new.html.erb where line #2 raised:

No route matches {:action=>"create", :new=>"new", :controller=>"ads"}

 <h1> New Ad</h1>
 <% form_for @ad, url:{action: "create"} do |f| %>
 <%= f.text_field :name %>

I am a beginner in Rails but as per my understanding , there is some problems in the config/route.rb ..

I have declared following routes in this file...

get 'ads/:new'=>'ads#new'
get 'ads/:create'=>'ads#create'
get 'ads/'=>'ads#index'
get 'ads/:id'=>'ads#show'

Last is the controller file where i have declared my functions:

class AdsController < ApplicationController
def new

Let me know if some more information is required.

1 Answer 1


Hey @Praveenks if you're a beginner in rails, I would recommend you to use the scaffold generator.

rails generate scaffold ads attribute1:type attribute2:type...

In this way rails generates for you the controller, views and routes for your Ads model.

By the way, to create the routes you want to, try the follow in your routes.rb file:

resources :ads, only: [:new, :create, :index, :show]

I hope it helps :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.