Hi All,
I cant for the life of me work out why the form isn't rendering... I have attached an image of the file without the rendered form.
I've attached all the code from the controller, route, and views html file thingy, and the master html file thingy as well... You can probably tell I am a complete beginner. I have rails 3 I think and have managed to get other pages from this application working such as index showing all rows on the database and also a page with individual rows from the database
class AdsController < ApplicationController
def new @ad = Ad.new end
def show @ad = Ad.find(params[:id]) end
def index @ads = Ad.find(:all) end end
Mebay::Application.routes.draw do
match '/ads/new' => 'ads#new' match '/ads/create' => 'ads#create' match '/ads/:id' => 'ads#show' match '/ads' => 'ads#index'
resources :ads
end
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Ads: <%= controller.action_name %></title> <%= stylesheet_link_tag 'default.css' %> </head> <body> <div id="wrapper"> <div id="header"> <div>
<h1>MeBay</h1> <ul id="nav"> <li><a href="/ads/">All Ads</a></li> </ul> </div> </div>
<div id="content"> <%= yield %> </div> <div id="clearfooter"></div> </div> <div id="footer"></div> </body> </html>
<h1>New ad</h1> <% form_for(@ad,:url=>{:action=>'create'}) do |f| %> <p><b>Name</b><br /><%= f.text_field :name %></p> <p><b>Description</b><br /><%= f.text_area :description %></p> <p><b>Price</b><br /><%= f.text_field :price %></p> <p><b>Seller</b><br /><%= f.text_field :seller_id %></p> <p><b>Email</b><br /><%= f.text_field :email %></p> <p><b>Img url</b><br /><%= f.text_field :img_url %></p> <p><%= f.submit "Create" %></p> <% end %>
Attachments: http://www.ruby-forum.com/attachment/6737/No_Forms_Showing.jpg