I am new to these forums, and to Rails...I'm not new to web development but I haven't worked in it for a good 5 years or so. This book is quickly bringing me up to speed with everything I need to know to build a cutting edge web application.
My question lies on pages 175-177 of Chapter 6....specifically regarding the re-rendering of the form...when I look at the generated HTML of the rerendered form I do not have a FieldWithErrors div around my text field(s).
I feel like this is because of an error is the coding we do for the create method in the stories_controller...specifically, why can we use the if/else clause to check if @story saves, if we never actually tell @story to save, you know?
Maybe I am just completely missing something here.
Here is my code....i typed it at first, and when it wasn't working i just went through and copied from the code archive, but it still doesn't seem to work.
class StoriesController < ApplicationController
@story = Story.find(:first, :order => 'RANDOM()')
@story = Story.new
@story = Story.new(params[:story])
flash[:notice] = 'Story submission succeeded'
render :action => 'new'
class Story < ActiveRecord::Base
validates_presence_of :name, :link
<% form_for @story do |f| %>
name: <br />
<%= f.text_field :name %>
link: <br />
<%= f.text_field :link %>
<%= submit_tag %>
<% end %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
content="text/html; charset=utf-8" />
<%= stylesheet_link_tag 'style' %>
<% unless flash[:notice].blank? %>
<div id="notification"><%= flash[:notice] %></div>
<% end %>
<%= yield %>
Does anyone know what I am doing wrong?
Thanks so much