Hi all
I wrote a small form and I am trying to check if the fields are
populated.
My Model is:
class Contact < ActiveRecord::Base
validates_presence_of :name, :email, :body
validates_length_of :body, :maximum =>2000
end
-----Controller
class ContactController < ApplicationController
def new
@contact = Contact.new
end
def create
@contact = Contact.new(params[:contact])
@contact.save
end
end
------Viewers
New view
<%= error_messages_for :contact %>
<% form_for @contact, :url => { :action => 'create' }, :html => {
:method => :post } do |f| %>
<fieldset>
<legend>Please send your message: </legend>
<p><label>Your Name:<br /><%= f.text_field :name, :size => 25
%></label></p>
<p><label>Your email:<br /> <%= f.text_field :email, :size => 25
%></label></p>
<p><label>Message:<br /><%= f.text_area :body, :rows => 10, :cols => 30
%></label></p>
<p><label><%= submit_tag 'Submit' %> </label></p>
</fieldset>
<% end %>
Create view
<h2>Thank you for your interest in my site</h2>
When the entry fields are not populated the forms shows the create view
and does not show any error message. why?
thanks
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---