Aidan Finn has written what may be the most comprehensive walkthrough of developing an authentication system in Rails. He starts from the migrations and covers every step of the process, right through to the tests. If you want to see how a Rails developer produces an entire block of functionality from start to finish, this is worth reading. Read More
Jeremy McAnally is writing a Ruby and Rails book called “Mr. Neighborly’s Ruby and Rails” and what an interesting book it’s turning out to be. He’s going to sell the finished item for $14 as a print book, $9 as an ebook, and it’s due to be finished in the next few months. For now though, you can download the first chapter for free. It’s a really cool introduction to Ruby, ideal for existing programmers or Rails developers who don’t know much Ruby yet.
The fonts and the feel are really ‘olde-worldy’ and I’m thinking this could be a big hit. Read More
A few days ago I learned about Curvy Corners, an incredible JavaScript that lets you put rounded corners on your DIV elements that can do anti-aliasing and handle any size border. It’s the best rounded corner script so far.
Craig Webster saw it too and has created a Curvy Corners in Rails helper method that means you can do stuff like:
<% curvy_div(:tl => false, :br => false) do -%>
Oyy, stylish.
<% end -%>
Very neat. Read More
RailsHelp.com has possibly the simplest homepage in the world. Just type in what you’re searching for, and off you go. It’s a nice change to digging through the regular API documents. Read More
If you’re on Windows and have been having trouble with your database adapters, this post about new Ruby database adapters for Windows might just be for you. Now, back to TextMate… :) Read More
Michael Gorsuch demonstrates how to add SSL to your Rails app in 5 minutes. Very simple and very effective. Read More
A few months ago I was getting fed up of having to create new ActionMailers from scratch on my Rails applications, so I decided to come up with a ‘generic’ way to cover all the bases. Instead of creating multiple mailers, you create a single mailer and append generic methods. The content goes to the regular RHTML files and you send through whatever you want from your controllers. See Simplifying ActionMailer development in Ruby on Rails. There’s probably a lot that could be done to it now, but it works great for me.
An example ActionMailer class: Read More
class Mailer < ActionMailer::Base
helper ActionView::Helpers::UrlHelper
def generic_mailer(options)
@recipients = options[:recipients] || “me@privacy.net”
@from = options[:from] || “me@privacy.net”
@cc = options[:cc] || “”
@bcc = options[:bcc] || “”
@subject = options[:subject] || “”
@body = options[:body] || {}
@headers = options[:headers] || {}
@charset = options[:charset] || “utf-8″
end
# Create placeholders for whichever e-mails you need to deal with.
Settings is a new plugin for Rails that lets you have a basic hash of ‘settings’ or configurations for your application without having everything hardcoded. Example: Read More
Settings.admin_password = ‘supersecret’
Settings.date_format = ‘%m %d, %Y’
Settings.cocktails = ['Martini', 'Screwdriver', 'White Russian']
Settings.foo = 123
Rodney Ramdas has put together a small application called “Learn Ruby” that shows the freely available version of the Pickaxe Ruby book alongside an instance of irb, meaning you can work through the examples and tutorials more freely. Note that it’s for OS X only.
If you want something similar, but which lets you use a Ruby interpreter direct from your Web browser, try out why’s infamous and incredibly clever Try Ruby! Read More
RailsTidy is a plugin for Rails, by Damien Merenne, which validates your RHTML templates, the HTML output from your functional tests, and tidies up the HTML generated by Rails. Read More
It’s a few months old, but this guide to creating your own role based authentication system in Rails is pretty good. It doesn’t use any plugins other than the LoginGenerator. Read More
Craig Webster has posted several times over the few days about his adventures with sockets in Ruby. He provides nice code examples (even doing socket stuff direct from irb!) and his explanations are useful if you know what you’re doing with Ruby, but haven’t tried doing any TCP or socket work yet:
- Absolute basics: Connecting to ports – First, Craig looks at how easy it is to connect to a remote port and how to check if a port is open.
- Concurrent socket programming – Craig moves on to using Ruby threads to connect to multiple ports at the same time, building a very basic port scanner.
When using Rails it’s easy to forget there’s any other way. Sometimes, however, it’s useful to access databases outside of that environment. Luckily, ActiveRecord can be used separately from Rails, and Craig Webster demonstrates how. Read More
Devin Steffler shows you how to load over 100000 countries, states, and towns into your Rails app’s database, from how to get the data to the code to transform the data into database entries. Read More
Step 1: Get the Yahoo-Ruby API. It’s only a small Ruby file. Its only dependencies are net/http and REXML that come with Ruby anyway.
Step 2: Make sure you have a Yahoo! API ID. If you don’t, get one now.
Step 3: Use a script like this one from O’Reilly’s Yahoo! Hacks book. The code can be as simple as this: Read More
obj = WebSearch.new(‘insert app ID’, ‘chunky bacon’, ‘phrase’, 10)
results = obj.parse_results
# results now contains an array of hashes
puts results.inspect