Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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 :)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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