I am, probably, a bit newer then new, even though I program for 10+
years.
I can program RPG(Mainframe), VB(Lotus Notes), some Delphi.
I went through “ONLamp_com Rolling with Ruby on Rails/cookbok” tutorial
and I made some kind of fancy rhtmls with very basic functions.
My goal is to make a db, put on the web for the group where I belong and
others (fly fishing).
I am currently reading “Programming Ruby” book.
One thing definetely screws up my sweet dreams: how to do validation?
I know “if” and “else”, but
where to put them?
in which folder?
how to pop up or display message?
Is the book I am reading is the proper book for me at this time?
What would you suggest me to read?
One thing definetely screws up my sweet dreams: how to do validation?
I know “if” and “else”, but
where to put them?
in which folder?
how to pop up or display message?
Is the book I am reading is the proper book for me at this time?
What would you suggest me to read?
I’d just like to put my support behind the Agile Web Dev with Rails
book. I started there and I think it is a superb book by a couple of
very clear thinking and clear writing people.
Frank
----- Original Message -----
From: “Bruce B.” [email protected]
To: [email protected]
Sent: Wednesday, December 14, 2005 8:55 AM
Subject: Re: [Rails] Where to start?
One thing definetely screws up my sweet dreams: how to do validation?
I know “if” and “else”, but
where to put them?
in which folder?
how to pop up or display message?
Agile Web D. explains all of this. Definitely get it!
In short validation/popup goes in the model like this:
validates_format_of :image_url,
:with => %r{^http:.+.(gif|jpg|jpeg|png)$}i,
:message => “mist be a URL for a GIF, JPG,
JPEG, or PNG image”
The agile book is still good, but the newest features aren’t documented
(RJS templates for example). But you’ll learn all but the most advanced
things.
One thing definetely screws up my sweet dreams: how to do validation?
I know “if” and “else”, but
where to put them?
in which folder?
how to pop up or display message?
You know how the web works?
you click the submit-button of your form
the application checks the data in the form
the application generates HTML and sends it to the browser
the browser displays the HTML
So the message should be in the result HTML. If you do a:
ruby script/generate scaffold Post
And open models/post.rb you should see something like:
class Post < ActiveRecord::Base
end
A Post has a title. And every post should have a title so you must type
in the form or get an errormessage. We need to add a validation for
this:
class Category < ActiveRecord::Base
validates_presence_of :title
end
This validates the presence of the title. This will be checked every
time you save a Post.
The message should be above the form:
<%= error_messages_for ‘post’ %>
Title
<%= text_field 'post', 'title' %>
The first line displays all error messages.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.