Forum: Ruby on Rails Where to start?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Igor Z. (Guest)
on 2005-12-13 22:17
My name is Igor.

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?

I appriciate your help.

Happy Holidays.
Bill G. (Guest)
on 2005-12-13 23:04
(Received via mailing list)
On 12/13/05, Igor Z. <removed_email_address@domain.invalid> wrote:
>
> 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?

Agile Web D. with Rails
http://www.pragmaticprogrammer.com/titles/rails/index.html

>
--
Bill G. (aka aGorilla)
Bruce B. (Guest)
on 2005-12-14 15:57
(Received via mailing list)
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.

bruce
Frank (Guest)
on 2005-12-14 20:01
(Received via mailing list)
I second that...

Frank
----- Original Message -----
From: "Bruce B." <removed_email_address@domain.invalid>
To: <removed_email_address@domain.invalid>
Sent: Wednesday, December 14, 2005 8:55 AM
Subject: Re: [Rails] Where to start?
Joe M. (Guest)
on 2005-12-14 20:16
(Received via mailing list)
Is the book still current for RoR 1.0?
unknown (Guest)
on 2005-12-14 20:46
(Received via mailing list)
On 12/13/05, Igor Z. <removed_email_address@domain.invalid> wrote:
>
> I am currently reading "Programming Ruby" book.

Awesome 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?

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"
Jules (Guest)
on 2005-12-14 20:51
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?

1. you click the submit-button of your form
2. the application checks the data in the form
3. the application generates HTML and sends it to the browser
4. 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' %>

<!--[form:post]-->
<p><label for="category_title">Title</label><br/>
<%= text_field 'post', 'title'  %></p>
<!--[eoform:post]-->

The first line displays all error messages.
This topic is locked and can not be replied to.