The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Thin Strand of Search-and-Replace Rails

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Red Handed

Posts: 1158
Nickname: redhanded
Registered: Dec, 2004

Red Handed is a Ruby-focused group blog.
Thin Strand of Search-and-Replace Rails Posted: Aug 16, 2005 11:12 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Red Handed.
Original Post: Thin Strand of Search-and-Replace Rails
Feed Title: RedHanded
Feed URL: http://redhanded.hobix.com/index.xml
Feed Description: sneaking Ruby through the system
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Red Handed
Latest Posts From RedHanded

Advertisement

If you’re playing with Rails and you want to better understand Ruby blocks, as well as method chaining, Matthew Bohnsack has a great one-liner, which boils to:

  Article.find_all.each { |a| a.body.gsub! \
    /src="\/(.*.(jpg|gif|png))/, 'src=\"http://bohnsack.com\1';
    a.save }

More like three or four lines, but still. He breaks it up, explains each part, with short paragraph-long lessons. I like how code like the above has the feeling of a sed recipe, but isn’t utterly cryptic.

Read: Thin Strand of Search-and-Replace Rails

Topic: Charles’ Desk Previous Topic   Next Topic Topic: Major Milestone in US Ruby History

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use