TipSnippet: Create a RSS feed

RSS is hot! So, you want to fit your new Rails app with one too! That’s easy, of course, but you just need to know what to do. This snippet will show you how to create an RSS feed form your RESTful articles. I’ll assume you know how to generate a resource named ‘article’ with a title, body and the default created_at and updated_at attributes. You’ll first need to add a new collection to your resource in config/routes.

Rails Tip Snippet: Create a comma-seperate list

Do you have the need to create a list of roles a certain user belongs to? Enumerate the users attached to a company? All you want is a simple list with the names seperated by commas. Users: John, Dick, Harry With Ruby on Rails this is really easy. You probably have a collection of user objects. All you want is a list of names: @users.collect{|u|}.join(', ') Read more Tip Snippets?

Rails Tip Snippet: Logging informational messages to your log

This “Rails Tip Snippet” is one in a series of small blocks of code that will make your life developing Rails applications a bit easier. This first snippet shows you how you can log informational message to your log file so you can track any important actions that happened. As an example you may want to log all user accounts that get deleted: