background preloader

Ruby on Rails

Facebook Twitter

Building Ruby on Rails 3 custom validators | PerfectLine Blog. Actually this post is not so much about just building custom validators for Rails 3 but more like a in-depth introduction to how validations work in the old and new versions of rails. And in addition to that I’m going to implement Rails 3 compatibility for the validates_existence gem, which we maintain and use extensively in our projects. The “old” stuff First I’m going to give you a quick overview of the gems current functionality, plus basic explanation of how it’s implemented. The gem itself contains a single validation – validates_existence_of, which validates belongs_to relations by making a query to the database and checking if the record actually exists. It supports regular relations (i.e where you know the class of the related class) and polymorphic relations, validations on both the association name and the association foreign key. Quick example of the validation in action: class Document <ActiveRecord::Basebelongs_to:entity, :polymorphic=>true endend The Rails 3 Way Convertify!?

Getting Started with Rails. 1 Guide Assumptions This guide is designed for beginners who want to get started with a Rails application from scratch. It does not assume that you have any prior experience with Rails. Rails is a web application framework running on the Ruby programming language. If you have no prior experience with Ruby, you will find a very steep learning curve diving straight into Rails. There are several curated lists of online resources for learning Ruby: Be aware that some resources, while still excellent, cover versions of Ruby as old as 1.6, and commonly 1.8, and will not include some syntax that you will see in day-to-day development with Rails. 2 What is Rails? Rails is a web application development framework written in the Ruby programming language.

Rails is opinionated software. The Rails philosophy includes two major guiding principles: 3 Creating a New Rails Project The best way to read this guide is to follow it step by step. 3.1 Installing Rails Open up a command line prompt. 4 Hello, Rails! RubyGems.org | your community gem host. Ruby on Rails Tutorial: Learn Rails by Example book and screencasts by Michael Hartl.

Michael Hartl Contents Foreword My former company (CD Baby) was one of the first to loudly switch to Ruby on Rails, and then even more loudly switch back to PHP (Google me to read about the drama). This book by Michael Hartl came so highly recommended that I had to try it, and the Ruby on Rails Tutorial is what I used to switch back to Rails again. Though I’ve worked my way through many Rails books, this is the one that finally made me “get” it. The linear narrative is such a great format. Enjoy! Derek Sivers (sivers.org) Founder, CD Baby Acknowledgments The Ruby on Rails Tutorial owes a lot to my previous Rails book, RailsSpace, and hence to my coauthor Aurelius Prochazka. I’d like to acknowledge a long list of Rubyists who have taught and inspired me over the years: David Heinemeier Hansson, Yehuda Katz, Carl Lerche, Jeremy Kemper, Xavier Noria, Ryan Bates, Geoffrey Grosenbach, Peter Cooper, Matt Aimonetti, Gregg Pollack, Wayne E.

About the author Copyright and license 1.1 Introduction. Code School - Rails for Zombies. The Ruby Toolbox - Know Your Options! RubyDoc.info - Library Listing. Ruby on Rails Screencasts - RailsCasts. #384 Exploring RubyGems. RubyGems can make it easy to add a feature to a Rails application, but it can also cause headaches down the road.

Here I give some tips on researching gems to decide which one to choose, or when to do it from scratch. Download: mp4Full Size H.264 Video (22.4 MB)m4vSmaller H.264 Video (11.4 MB)webmFull Size VP8 Video (9.61 MB)ogvFull Size Theora Video (31.6 MB)