State Machine Simulator
April 1st, 2008
If you need to create a wizard, with forward and back buttons for several different steps, a great way to do it is to use the acts_as_state_machine plugin.
But for just two or three steps, loading a whole plugin seems like overkill. Instead of loading a whole plugin, you can simulate the same functionality by dropping next! and previous! methods into your model like so:
# State Machine
# Guilt-free stateful modeling!
# These two simple methods simulate all the goodness of
# acts_as_state_machine without the added fat of an included plugin.
def next!
next_step = case self.state
when "step1"
"step2"
when "step2"
"step3"
when "step3"
"step3"
end
self.update_attribute(:state, next_step)
end
def previous!
previous_step = case self.state
when "step1"
"step1"
when "step2"
"step1"
when "step3"
"step2"
end
self.update_attribute(:state, previous_step)
end
def current_step
@current_step ||= self.state
end
#Safari Inline Elements Bug?
March 28th, 2008
I was debugging css today, and I ran across some strange behavior with our pagination links. Occasionally the number of pages would wrap around, which is normal, but I noticed that in Safari the right side of the last element in each row was getting chopped off.
Here’s a picture in Safari (and Webkit):

Here’s the same page (what it’s supposed to look like) in Firefox:

Here’s the HTML:
<div id="pagination-links"><strong>Pages: </strong>
<ul>
<li class="selected"><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">4</a></li>
<li><a href="#">5</a></li>
<li><a href="#">6</a></li>
<li><a href="#">7</a></li>
<li><a href="#">8</a></li>
<li><a href="#">9</a></li>
<li><a href="#">10</a></li>
<li><a href="#">11</a></li>
<li><a href="#">12</a></li>
<li><a href="#">13</a></li>
<li><a href="#">14</a></li>
<li><a href="#">15</a></li>
<li><a href="#">16</a></li>
<li><a href="#">17</a></li>
<li><a href="#">18</a></li>
<li><a href="#">19</a></li>
<li><a href="#">20</a></li>
<li><a href="#">21</a></li>
<li><a href="#">→</a></li>
</ul> of 21 total pages
</div>
And the CSS:
#pagination-links {
color: #404040;
line-height: 25px;
margin: 0 15px 15px 15px;
font-size: 12px;
width: 300px;
}
#pagination-links strong {
padding-right: 10px;
}
#pagination-links ul {
display: inline;
}
#pagination-links ul li {
display: inline;
}
#pagination-links ul li a {
background-color: #fff;
border: #c5c0c0 1px solid;
color: #5b969f;
padding: 2px 6px;
text-decoration: none;
}
#pagination-links ul li a:hover {
border-color: #404040;
color: #404040;
}
#pagination-links ul li.selected a {
background-color: transparent;
border: 0;
}
This display behavior only appears in Safari. It looks correct in Firefox (2 and 3), as well as IE 6.
Safari version: 3.1 (5525.13) Webkit revision: r31388
At first blush, this looks like a browser bug. But before I get too much farther in tracking this down, has anyone else encountered this? Any insight would be appreciated!
Update:
Here’s a zipped file with everything you need to reproduce the bug: cut-off-test.zip (86k)
#attachment_fu on Edge Rails
February 26th, 2008
Speaking of Edge Rails… attachment_fu will break because Edge has extracted callbacks out into a separate module.
To prevent unnecessary pain and suffering, see http://blog.methodmissing.com/2008/1/19/edge-callback-refactorings-attachment_fu/
Just paste that whole blob at the bottom of your attachment_fu.rb file and you’re good to go.
#check_box broken in Rails 2.0.2?
February 26th, 2008
I was having an awful time submitting a form with a check_box. No matter what I did, it would only return “0” or “false”, never “1” or “true”, no matter how hard I mashed the mouse button on the check box.
<%= check_box :fund, :tax_deductible %> <%= f.label :tax_deductible %>
I finally tried moving to edge Rails (from Rails 2.0.2), and the problem went away. Anyone else experience this?
#Date Parsing Strangeness
February 22nd, 2008
Calculating dates is arguably one of the most complicated parts of programming. Ruby eases the stress with some great tools to help parse and calculate dates.
But lately I’ve run into some really strange behavior, and I’m kind of at a loss. I’m posting it here in the hopes that somebody can shed some light on why this is happening.
Basically I’m getting inconsistent results with the different parsing libraries. I’d like to be able to pass dates like “2/22”, “2/22/08”. Parsing a date like “2/22/08” should return February 2, 2008. But here’s what happens in the different parsing libraries:
>> Time.parse("2/22/08").to_date
=> Fri, 22 Feb 2008
>> Chronic.parse("2/22/08").to_date
=> Fri, 22 Feb 2008
>> Date.parse("2/22/08")
=> Wed, 22 Feb 0008
But as you can see, passing “2/22/08” to Date.parse we get the Year of our Lord, uh… 8. That’s obviously not right.
What about a date with no year, like “2/22”? I’d like it to return the date in the current year.
>> Date.parse("2/22")
=> Fri, 22 Feb 2008
>> Time.parse("2/22").to_date
=> Fri, 22 Feb 2008
>> Chronic.parse("2/22", :context => :past).to_date
=> Tue, 15 Feb 2022
Date and Time do pretty well, but even with :context => :past Chronic returns the year 2022.
What’s going on here? I’ll keep playing with it, but any insight would be appreciated.
#I'm Beginning to Get Git
February 15th, 2008
I saw a great presentation about Git by Rein Henrichs at Austin on Rails the other night. I’ve heard a lot about Git, but based on what Rein said, I finally and decided to give Git a try. So far I have been extremely impressed. So impressed, in fact, that I’ve migrated the Donor Tools repository to Git, and I haven’t looked back since.
One of the best little benefits is the fact that Git only puts one .git folder at the top-level of your project, unlike Subversion, which litters every folder in your project with a .svn directory. Nice. I’m also loving the ability to branch and merge without tearing a whole in the space-time continuum.
Git takes a little getting used to. It was created by some extremely smart people (namely Linus Torvalds, who also created Linux), so the inner workings are completely beyond the scope of my comprehension. (Thanks for trying to explain it though Rein.) One of the toughest things to wrap my mind around is how to push and pull branches from remote repositories. But even baby steps with Git are more powerful than Subversion, so I’m really looking forward to becoming more experienced with Git.
#The cost of freedom
February 1st, 2008
The cost of freedom is always high.
Most of the republican candidates in the race today are in favor of maintaining the war in Iraq. One of them even said that he’d keep it going for 100 years if necessary!
Now, I once heard that The War is costing us about $100,000,000,000 ($100 billion) per year. In sheer morbid curiosity, I was wondering how much that would end up costing us after 100 years. So I fired up Numbers and ran a quick, very simple calculation. Using an inflation rate of 3%, 100 years of war with Iraq would cost us…
$60,728,773,269,521
That’s 60 trillion dollars.
Please correct my math. I was wondering, maybe you can explain this to me… how would we come up with $60 trillion and still lower taxes?
#Church Website Survey Final Report
January 21st, 2008
I’m a little late on posting this – I was so relieved to be finished with my graduate research project that I have been loathe to pick it up again. But, I promised to post the results, and folks have been asking about it.
Quick link to the report: http://www.artofmission.com/survey/
We had a great response for Survey Version 2.0 — 219 responses in about a month! In all, I looked at over 220 church websites. The feedback we received was wonderful – thanks so much to everyone who participated.
Surprisingly, I found that there was not as much connection as I expected between the cost of a church’s website and its quality. Of course, in my opinion, more expensive church websites tended to look better. But many churches are endowed with generous and talented volunteers that help keep the costs low.
The most important factor seemed to be attitude. From my executive summary:
churches that embrace the web as an opportunity tend to get more value out of the medium than those that approach it as a necessary evil. It can seem obvious when a church has forgotten about their website, or “slapped one together” just in case it turns out that they need one. At the same time, it can also be obvious which churches genuinely expect to connect with people through their website.
You can download the final paper and presentation from http://www.artofmission.com/survey/. Enjoy!
P.S. Congratulations to Garet Robinson, who won the iTunes gift card! (Garet was randomly selected by a computer program from a list of everyone who filled out the second survey and provided an email address.) Happy listening Garet!
#Introducing Donor Tools
December 14th, 2007
With a little bit of fanfare, we recently announced Donor Tools, a new donor management app for non-profits.
I used to work at a small non-profit, and I was never satisfied with the software that was available to us. It all seemed either too hard to use, too clunky, too slow, or 20 years old. Ever since then I dreamed of making a killer app for non-profits – one that’s easy to use, has just a few features that every non-profit needs (and not a lot of extra features that only a few need), helps non-profits get to know their donors better, and is affordable.
We’ve been writing code for Donor Tools since July, and it’s exciting to watch it take shape. There’s still a lot to be done. If you’d like to keep an eye on the development progress, be sure to subscribe to the news feed.
Pretty soon we’ll need some beta testers. If you know of any nonprofit organizations that might be interested in helping us beta test, please invite them to subscribe to the mailing list on www.donortools.com
#Radiant Factory
November 29th, 2007
Say hello to Radiant Factory, our new theming service for Radiant CMS.
Basically, Radiant Factory is a theming service for Radiant CMS. We take your design and content and turn it into a series of layouts, snippets, and pages that you (or your client) can manage with the fabulous Radiant content management system.
I’ve fallen in love with Radiant’s easy, straightforward website administration. Honestly, I always hated content management and website update tasks until Radiant came along. The idea behind Radiant Factory is simple: share the love. Radiant Factory is my way of helping web designers provide an even better product to their clients.
So check it out and let me know what you think. Your feedback is appreciated!
#Sitepoint Rails Book Giveaway
November 27th, 2007
Only five days left to get a free copy of Sitepoint’s Build Your Own Ruby on Rails Web Applications
It’s a pretty good book for beginners – very complete; over 400 pages.
#Church Website Survey Version 2.0
November 19th, 2007
Get it while it’s hot
If you’re a church leader, pastor, staff, volunteer, or otherwise involved in your church’s leadership, please go check out Version 2.0 of our Church Website Survey.
This time around, we’re tying to gauge how churches are investing in and utilizing technology.
The results from the last survey are also available now. Just go to www.artofmission.com/survey to download the raw results.
Oh, and if you complete the survey before November 30, you’ll be entered in a drawing to receive an iTunes gift card. So tell your friends!
Take the Survey
#We're a Forever Family!
November 16th, 2007
Introducing Emma Karis Heneise! Emma means complete or universal, and Karis means grace or undeserved gift. She is such a blessing, and we are so thankful that she is ours forever. As the judge said, we were just waiting for the court to make legal a commitment that was already made in all of our hearts.
Yesterday, Emma joined with over 60 other children at Austin’s Adoption Day. The Juvenile Justice Center was transformed into a huge party with games and celebrations for everyone. The courtrooms were packed with stuffed animals, and the judges happily made legal one adoption after another! It was incredible to be part of such a big event. It really made me excited to see all of the other families. I really hope to adopt again someday (when our girls are just a bit older!).
Here we are: Ryan, Bethany, Emma (almost 15 months), and Selah (4 months)
Also posted on Becoming a Midwife
#Wish List: Location-Based Security
October 27th, 2007
I like my MacBook Pro to be secure, so I’ve enabled “require password when waking from sleep or screen saver”. It’s a pain to have to type the password every time I open the lid, but I feel better knowing that a thief would have a harder time getting my files if they did manage to pry my beloved MBP out of my cold, dead fingers.
So I’m relatively happy with the security features. But there is one thing that would make me Really Happy: I guess you could call it “network-context security” or “location-based security”
Location-based security basically means that the security settings would change depending on what network you’re connected to. So if I’m at home, connected to my home wifi network, the security would be at its loosest. I could open and close the top all day long without putting in my password. But as soon as that network goes away, or I get out of range of my house, the tougher security would kick in. So if I wind up at the coffee shop, the computer would automatically know to bump up the security settings. Returning home again, my security settings would be reduced.
How sweet would this be? It seems like one of those sugary little features that Apple would bake in to make people feel really warm and fuzzy, but I’d settle for a shareware app. Anyone know if such a thing exists? Is there a hidden feature in Leopard for this?
#More Productive with Windows Vista
September 12th, 2007
Despite some well-documented claims to the contrary, I think Windows Vista has really increased my productivity.
I got Vista a couple of weeks ago in order to test web pages in IE 7 for Moral Metic. We do have a Windows XP machine that I could have used, but it’s our mission-critical Quickbooks machine, so I didn’t want to risk setting up IE 7 and messing up Quickbooks.
Anyway, ever since I installed Vista under VMWare on my Mac Mini, I have been SO much more productive. Without Vista, I never would have had time to do things like organize my office, put up additional shelves in the closet, and rearrange furniture. All while waiting for Vista to do things. I am tremendously thankful for these opportunities to do mundane tasks that Vista has opened up, and I look forward to a future where we all have more time for things that just aren’t that important, and less time to do actual work.
Thanks Microsoft!
#Subscribe
Network
Archives
- April 2008 (1)
- March 2008 (1)
- February 2008 (5)
- January 2008 (1)
- December 2007 (1)
- November 2007 (4)
- October 2007 (1)
- September 2007 (1)
- August 2007 (3)
- July 2007 (2)
- June 2007 (5)
- May 2007 (6)
- April 2007 (3)
- March 2007 (4)
- February 2007 (5)
- January 2007 (5)
- December 2006 (6)
- November 2006 (1)
- October 2006 (8)
- September 2006 (12)
- August 2006 (7)
- July 2006 (6)
- June 2006 (5)
- May 2006 (2)
- April 2006 (17)
- March 2006 (15)
- February 2006 (7)
- January 2006 (12)
- December 2005 (25)
- November 2005 (11)
- October 2005 (3)
- September 2005 (2)
- August 2005 (4)
- July 2005 (5)
- June 2005 (1)

