11175
(-- --)
May 2, 2008, 7:21am
1
I have crated controller classified
class ClassifiedController < ApplicationController
def list
@classifieds = Classified.find(:all)
end
def show
@classified = Classified.find(params[:id])
end
def new
@classified=Classified.new
end
def create
end
def edit
end
def update
end
def delete
end
end
and created classified/new.rhtml
Attachments:
http://www.ruby-forum.com/attachment/1830/new.rhtml
start_form_tag has been deprecated and subsequently removed. use
form_tag instead:
<% form_tag :action => :foo, ... do %>
form elements here
<% end>
11155
(-- --)
February 19, 2010, 7:03pm
3
While doing a tutorial on tutorialpoint, I had the same problem! I made
the change, but I get another error :
NoMethodError in Book#new
Showing app/views/book/new.rhtml where line #4 raised:
undefined method `title' for #<Book id: nil, created_at: nil,
updated_at: nil>
Extracted source (around line #4 ):
1: <h1>Add new book</h1>
2: <%= form_tag :action => 'create' %>
3: <p><label for="book_title">Title</label>:
4: <%= text_field 'book', 'title' %></p>
5: <p><label for="book_price">Price</label>:
6: <%= text_field 'book', 'price' %></p>
7: <p><label for="book_subject">Subject</label>:
here is the new.rhtml file:
<h1>Add new book</h1>
<%= form_tag :action => 'create' %>
<p><label for="book_title">Title</label>:
<%= text_field 'book', 'title' %></p>
<p><label for="book_price">Price</label>:
<%= text_field 'book', 'price' %></p>
<p><label for="book_subject">Subject</label>:
<%= collection_select(:book,:subject_id,@subjects ,:id,:name) %></p>
<p><label for="book_description">Description</label><br/>
<%= text_area 'book', 'description' %></p>
<%= submit_tag "Create" %>
<%= end_form_tag %>
<%= link_to 'Back', {:action => 'list'} %>
thanx indeed for your help!
Tantor
Frederick Cheung wrote: