The Ruby and Rails community linklog
Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!
Submit a post
Post Preview
Note: Only the first pargraph is shown on the front page and overly long paragraphs may be broken up.
Sanitize: A whitelist-based Ruby HTML sanitizer
Sanitize is a new whitelist-based HTML sanitizer for Ruby. Using a simple configuration syntax, you can tell Sanitize to allow certain elements, certain attributes within those elements, and even certain URL protocols within attributes that contain URLs. Any HTML elements or attributes that you don’t explicitly allow will be removed.
Leverage ActiveRecord with Non-Database Backed Objects
ActiveRecord comes with a lot of nice things that aren’t dependent on having a database backed model. The most obvious example of this is the validation framework baked into ActiveRecord. Also, there are several plugins which add some useful behavior to ActiveRecord objects but don’t rely on having a database. [more inside]
Scope Columns
ColumnScope to select only certain values from your DB. I often need only single attributes of an ActiveRecord instance. In the past I used something like select_values(SELECT_SQL) or find(:all, :select => SELECT_SQL_FRAGMENT).map! { |r| [r.title, r.teaser]} to conservativly get them. After some time I felt the redundant code tiring and wrote this tiny plugin on top of named scopes. Usage examples:
Article.selects(:title_and_teaser).with_author.all # => [<Article ...]
Product.ordered_by_name.select_all(:name_and_prize) # => [['Apple Pie', 3.80], ...]
You can find the source and more examples in my repository @ github.
Lockdown improvements
I’m working on a new version of Lockdown and would like to hear of any suggestions. more info…
In light of the Rails/Merb merge, how DHH is still being a jerk
- The Rails/Merb merge isn’t necessarily a bad idea. But rails-core needs to actually have a conversation about why people (a number of merbists) were so pissed off at the rails community that they left. And that can’t happen until someone acknowledges that there was a legitimate problem.
Ruby callbacks
This blog post is about ruby’s callbacks(hooks): what are the available ones,and how practically we can use them? Ruby callbacks
Scalable Datasets with Bloom Filters and Ruby
When you’re working with large datasets it’s always nice to have a few algorithmic tricks up your sleeve, and Bloom Filters are exactly that - often overlooked, but an extremely powerful tool when used in the right context. Learn the theory and get started with Bloom Filters in Ruby.
Ever been confused by Leopard's patch level for Ruby?
In the comments on bryanl’s blog post, “So, if you are using a mac, wanna know why you are using the wrong ruby?”, Laurent Sansonetti explains the patch level for the Ruby version maintained by Apple.
Valid Attributes and Records for Unit/Integration testing
valid_attributes a Rails plugin that produces valid Records and attributes from a given yml file.
user = valid User #reord (unsaved)
strange_user = valid User, :name=>'Mr Strange' #slightly modified version...
Also Included: assert_invalid_attributes, a validation to test all validation rules DRY and with readable output.
#--> Failure: User.email expected to be invalid when set to s@sss
asser_invalid_attributes User, :email=>[nil,'','s@sss','xx@dd.s'], ...
Getting Started With Story testing in Cucumber
2 quick tutorials to get started with story-based testing, including some common steps and real-life-stories Cucumber Part 1 and Cucumber Part 2
Ruby reflection 2
This is the second post related to ruby’s reflection API, the previous post was an extensive intro to this topic. While the current one will be lighter somehow, it would require you to focus a bit more on the content. Here we go:
Another Ruby weather API - NOAA
A new gem for pulling current conditions and daily forecasts from the National Oceanic and Atmospheric Association’s weather service (a.k.a. weather.gov).
Ghetto contexts in Rails tests
If you’re between a rock and a hard place because you can’t add Shoulda or RSpec dependencies to your tests, check out this solution using lambdas.
Rails Monoculture Over
Foy Savas covers the Rails-Merb merge and what to make of it.
merb's provides/display in rails
DHH recently posted about bringing merb’s provides/display into rails. Here is my take with a few tweaks.
Rails Unit Testing Using Context
A shallow dip into testing using Jeremy McAnally’s Context gem
New rails plugin for easily adding emailed verifications to your models
Fixie Verifications is a Rails plugin that lets you add emailed verifications to your models. From the README: [more inside]
Prototype UI AutoComplete in Rails
Prototype UI autocomplete Using Ruby on Rails
Ezra Zygmuntowicz, Dec 15th 2008
patch -p0 rails-3.0 < merb-core.patch; done, there no more merb vs rails problems
rSnipt - Ruby Snipt Library!
rSnipt is a Ruby library I wrote to interact with Snipt.net. There’s also a CLI client, which I think will be really useful to all Rubyists. Check it out, and enjoy! :)
Alternative Framworks and Rarb (Rails + Merb)
What is the fate of alternative framworks in the world of Rarb (Rails + Merb)?
Speeding up method missing
Some consideration when using method_missing and a simple technique to speed up method missing
Merb and Rails merge: Become Rails 3.0
This is a historic moment in the ruby community. Read all about it: The day Merb joined Rails, Ruby on Rails blog, Yehuda Katz’s post, Carl Lerche’s post, The Merbist, Ezra’s post
Merb and Rails Merge
Is April 1st late this year? DHH announces that Merb is being merged into Rails 3! Wowsers!
Run JavaScript (or JRuby) with all the power of desktop Java in the browser
Trephine makes creating ultra-rich web applications easy by bringing the full power of the desktop to the web developer. This is achieved by executing privileged JavaScript code through a tiny (~20kb) signed Java applet. With Trephine you can: read and write from the file system, open sockets for listening, access the system clipboard, and much more. [more inside]