Shock and Awe

Seems like with every new piece of the tutorial, I'm following comes another new 1-3 lines of code that just makes me say "that's it?". The incredible thing really is that you encounter them about 3 times a chapter!There are about 5 things just from this afternoon that I could really put here but I'll share one example. Enforcing required fields in a form + displaying formatted error messages to the user when they fail to meet the requirements. This sounds so simple when you say it outloud, so really… it SHOULD be this easy. It's just nice that it finally is!

Add to my model class:
validates_presence_of :name, :email, :address, :pay_type

Add to my view (rhtml):

That's it. Now if you don't enter the name (or any other) field in my form, it will stop you from proceeding due to that first line, and display the reason in the second… not bad.

Equally amazing me this afternoon was my response from The Pragmatic Programmers on the hardcopy of my book (which still hasn't arrived). While I did expect them to ship me a new copy without too much hassle (if you've read the book you know that they put a lot of value in a positive customer experience), but I wasn't expecting a response 20 minutes later appologizing for the inconvenience and telling me that arrangements were made to reship the book! Not to mention the fact that it wasn't a form letter – on a Saturday!


Leave a comment

Filed under Agile Software Dev, rails, Ruby

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s