Posted over 2 years back at GIANT ROBOTS SMASHING INTO OTHER GIANT ROBOTS - Home
What is your Ubiquitous Language for authentication?
Common language includes “logging in”, “registering”, “joining up”, “creating an account”, “signing up”, & “signing out”.
Do you interchange these words in your UI? How about in your application code? Tests? Does your whole team use the same language across all layers of the software?
When writing a library like Clearance, I feel the authors should take a stand on language to alleviate the mental burden on designers, developers, & business analysts involved in the project.
The decision is basically arbitrary. No one set of terms is truly better than the other. What’s important is to take the opportunity to standardize all the places this shows up in code.
So we picked “sign up”, “sign in”, & “sign out”, a lingual trinity of authentication.
We liked the symmetry. We liked that there was less of a chance of writing “log in” (sounds like a verb) or “log_in” in certain places and “login” (sounds like a noun) other places.
About a half a year later and we still feel good about the effect:
Tests
context "when signed out" do
setup { sign_out }
context "on get to new" do
setup { get :new }
should_deny_access
end
end
context "when signed in" do
setup { sign_in }
context "on get to new" do
setup { get :new }
...
end
end
context "when signed in as an admin" do
setup { sign_in_as Factory(:admin_user) }
context "on delete to destroy" do
setup { delete :destroy }
...
end
end
Application code
class UsersController < Clearance::UsersController
def create
...
sign_in(@user)
end
end
class ParticipationsController < ApplicationController
protected
def ensure_signed_in
unless signed_in?
store_location
flash[:failure] = "Please sign in to participate in this deal."
redirect_to sign_in_path
end
end
end
module NavigationHelper
def authentication_links
if signed_in?
signed_in_links
else
signed_out_links
end
end
def signed_out_links
[link_to("Sign up", sign_up_path),
link_to("Sign in", sign_in_path)]
end
def signed_in_links
[link_to("My Account", edit_user_path(current_user)),
link_to("Sign out", sign_out_path)]
end
end
UI
For something as common as authentication, familiarity for users breeds comfort. So what do the big boys do?
Basecamp is a little inconsistent, mixing sign in with login:


Apple is pretty as usual:

Google is perfectly consistent. Youtube & Gmail:



Ahh… sweet, sweet consistency.
Posted over 2 years back at GIANT ROBOTS SMASHING INTO OTHER GIANT ROBOTS - Home
What is your Ubiquitous Language for authentication?
Common language includes “logging in”, “registering”, “joining up”, “creating an account”, “signing up”, & “signing out”.
Do you interchange these words in your UI? How about in your application code? Tests? Does your whole team use the same language across all layers of the software?
When writing a library like Clearance, I feel the authors should take a stand on language to alleviate the mental burden on designers, developers, & business analysts involved in the project.
The decision is basically arbitrary. No one set of terms is truly better than the other. What’s important is to take the opportunity to standardize all the places this shows up in code.
So we picked “sign up”, “sign in”, & “sign out”, a lingual trinity of authentication.
We liked the symmetry. We liked that there was less of a chance of writing “log in” (sounds like a verb) or “log_in” in certain places and “login” (sounds like a noun) other places.
About a half a year later and we still feel good about the effect:
Tests
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
context "when signed out" do
setup { sign_out }
context "on get to new" do
setup { get :new }
should_deny_access
end
end
context "when signed in" do
setup { sign_in }
context "on get to new" do
setup { get :new }
...
end
end
context "when signed in as an admin" do
setup { sign_in_as Factory(:admin_user) }
context "on delete to destroy" do
setup { delete :destroy }
...
end
end |
Application code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
class UsersController < Clearance::UsersController
def create
...
sign_in(@user)
end
end
class ParticipationsController < ApplicationController
protected
def ensure_signed_in
unless signed_in?
store_location
flash[:failure] = "Please sign in to participate in this deal."
redirect_to sign_in_path
end
end
end
module NavigationHelper
def authentication_links
if signed_in?
signed_in_links
else
signed_out_links
end
end
def signed_out_links
[link_to("Sign up", sign_up_path),
link_to("Sign in", sign_in_path)]
end
def signed_in_links
[link_to("My Account", edit_user_path(current_user)),
link_to("Sign out", sign_out_path)]
end
end |
UI
For something as common as authentication, familiarity for users breeds comfort. So what do the big boys do?
Basecamp is a little inconsistent, mixing “sign in” with login>

Apple is pretty as usual:

Google is perfectly consistent. Youtube & Gmail:

Ahh… sweet, sweet consistency.
Posted over 2 years back at ChadFowler.com
Yesterday I asked on Twitter whether anyone was successfully using is_paranoid in a Rails application, because I had confused myself into thinking it couldn’t possibly work.
The problem I was having wasn’t is_paranoid’s fault, but it turns out it actually can’t do what I wanted it to do in its native state. The explanation of why is something I thought a number of Rubyists might benefit from hearing, so here it is.
Briefly, an explanation of is_paranoid: if you declare an ActiveRecord model to be paranoid, whenever you attempt to delete that model, is_paranoid will instead set a flag which indicates that the record is deleted. is_paranoid uses default_scope to filter out soft-deleted records in your queries. So you can act as if records are deleted without actually removing the rows. If is_paranoid is new to you but sounds familiar, you might be thinking of acts_as_paranoid, which is Rick Olson’s original implementation of this idea.
What I wanted to do for the specific application I’m working on is to declare that every model should inherit the is_paranoid behavior. Easy enough, I thought, given the way these things typically work in Rails’ inheritable accessor setup:
But when I tried to destroy an instance of (for example) Person, the regular ActiveRecord destroy code was invoked and the records were being actually destroyed. Bummer.
So I cracked open the code to is_paranoid and found this perfectly reasonable idiom:
At this point, after pretending I was an idiot for a few minutes, I realized that this code was indeed incapable of doing what I wanted it to do.
Some of you already know why. For the rest of you, let’s talk about how Ruby’s mixins fit into its inheritance mechanism.
Maybe it’s just me, but when I think of something getting “mixed in” to something else, I imagine the two things becoming intertwined. So, the natural assumption when mixing a module into a Ruby class would be that the methods of the module get intertwined with the Ruby class. And for the HelloWorld of mixins, that indeed appears to be the case:
But if you start mixing modules that implement methods the class also implements in, things don’t go quite as smoothly:
Instead of “Overridden do_something” as some might expect, this code prints “Doing something in Thing”.
Why?
Because when we mix a module into a Ruby class, we’re not actually intermingling the methods of the module and the class. Instead we’re inserting the module into the class’s inheritance hierarchy. A good way to see how this works is by using the “ancestors” method:
When a method is called on an instance of SubThing, you can see that it is looked up first in SubThing’s class, then Thing’s class, then in IneffectiveOverride, and so on.

(I used yuml to generate this. Cool site!)
To further demonstrate that mixins don’t really get “mixed in”, notice what happens when you try to include a module at multiple points in the inheritance hierarchy:
If a module is already present at a higher point in the hierarchy, it won’t be mixed in again.
So is_paranoid was apparently built without the goal of being able to mix it into ActiveRecord::Base. Sounds reasonable to me.
Posted over 2 years back at Rails Envy - Home
Episode 86. We bring you the latest news in the Ruby and Rails world. This week features co-host Nathan Bibler, tequila, a singing robot, and a Hoedown. What more could you ask for?
Subscribe via iTunes - iTunes only link.
Download the podcast ~14:00 mins MP3.
Subscribe to feed via RSS by copying the link to your RSS Reader

Runway is a GTD-style action management web application made by geeks for geeks. Created by the folks at Cogent, try a free demo at http://www.runwayapp.com.
NewRelic not only provides rails performance monitoring with RPM, but they also produce Rails Lab, a website dedicated to advice on tuning and optimizing Rails apps.
Show Notes
Posted over 2 years back at InfoQ Personalized Feed for unregistered user - Register to upgrade!
Google has announced they are working a new operating system called Google Chrome OS. Based on a Linux kernel with a new windowing system, the new OS is targeted at netbooks first. By Abel Avram
Posted over 2 years back at OnRails.org
I was playing with Cucumber and FunFx to drive a Flex application and it's really cool and created this screencast to show how this all works together. The first 5 minutes I build a Restfulx scaffolded Flex application. The following 5 minutes I configure the Flex app with FunFx, which is required to be able to drive the app from Cucumber. Then the main part which is 20 minutes of creating three cucumber scenarios that drives the Flex application. Check it out:
<object width="400" height="300"><param name="allowfullscreen" value="true"/><param name="allowscriptaccess" value="always"/><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=5502928&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1"/><embed src="http://vimeo.com/moogaloop.swf?clip_id=5502928&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object>
Testing Flex Apps with Cucumber from daniel wanja
The source code can be found on github
Enjoy!
Daniel
Posted over 2 years back at Jake Scruggs
This summer I'm revisiting my short apprenticeship at Object Mentor. I'll be posting commentary on all my posts from the summer of 2004 exactly 5 years later to the day.
Wednesday 7-7-04
Most of today was the State Map Compiler. We got it to work, but almost all the work was being done in a 600+ line class. Armed with a bunch of passing tests, we proceeded to brake just about all of them in the refactoring process. But, and this is important, we only broke one test at a time. The goal was to offload a whole mess of functionality into a bunch of other classes. By the time we got back to a refactored green, we had about 100 lines in the controlling method and much more readable code. Whoo!
Then it was time to do a real conversion of the OMwiki to FitNesse. Previously Paul and I had used a copy of the OMwiki files for practicing purposes. Today we shut down the OMwiki and ran our program on the wiki pages. Due to an unfortunate use of a backslash in a program designed to deal with Unix, our conversion program created a few thousand extra files. Sigh. You see, the Unix system uses forward slashes to denote directories so it sees backslashes as just another character. All those directories we thought were being created became strangely named files. And all the real files got dumped in the main directory. Too many files to delete, oddly enough. The 'rm' command stands for remove in Unix-speak. But apparently it has a limit as to how many files it can address. We actually had to write a program in Python just to delete the files. Then, on our second try we saw the resurgence of the strike-through (double dash) problem. Apparently there had been some changes after I left yesterday, but we went back to an earlier solution and that worked. As I had to dash out the door to make my train, everything was working on the new OMwiki site except for an unfortunate spelling of refactor (as 'refacator'). I'm sure they'll be able to fix that one without me.
Anyway, I'm putting today in the win column.
I'm not really sure why we couldn't have just copied the files, ran the program, got it up and working on the new wiki, and then shut down the old wiki. That would have involved too little stress I suppose.
As to the State Map (Machine?) Compiler, I think that may have been the first time I was able to see the power of having a comprehensive test suite so you can refactor at will. More and more I work with developers who've had testing forced on them and see it as a necessary, or perhaps unnecessary, burden. I really don't get that -- I find a well tested application very satisfying.
Posted over 2 years back at Segment7
imap_processor version 1.2 has been released!
IMAPProcessor is a client for processing messages on an IMAP server. It
provides some basic mechanisms for connecting to an IMAP server,
determining capabilities and handling messages.
IMAPProcessor ships with the executables imap_keywords which can query an
IMAP server for keywords set on messages in mailboxes, imap_idle which can
show new messages in a mailbox and imap_archive which will archive old
messages to a new mailbox.
Changes:
- 2 major enhancements
- imap_archive which archives old mail to dated mailboxes
- imap_idle which lists messages that were added or expunged from a mailbox
- 4 minor enhancements
- Added IMAPProcessor#create_mailbox
- Added IMAPProcessor#delete_messages
- Added IMAPProcessor#move_messages
- Disabled verification of SSL certs for 1.9
- 1 bug fix
- Fixed options file names, they should be Symbol keys
Posted over 2 years back at zerosum dirt(nap) - Home
We opened registration for the 2009 Rails Rumble yesterday. This is the third year in a row that we’re running the contest and it’s sure to be the best one yet. The build weekend is August 22nd-23rd but you need to register this week if you want a seat. If I were you, I’d go register now before it fills up ;-).
In other news, I’ll be presenting at the second Portsmouth Pecha-Kucha Night tomorrow, July 8th. I’ll actually be talking about the creative power of constraints, and describing our experiences organizing the Rumble will be a big part of that. If you’re in town, make sure to check it out. I’ve never done a p-k talk before but it sounds like it’s going to be a lot of fun.
Posted over 2 years back at has_many :bugs, :through => :rails - Home
Don’t think the nested layouts get any simpler in Rails.
1
2
3
4
5
6
|
module ApplicationHelper
def parent_layout(layout)
@content_for_layout = self.output_buffer
self.output_buffer = render(:file => "layouts/#{layout}")
end
end |
Now using the parent_layout helper method inside your layouts for nesting :
1
2
3
4
5
|
# items.html.erb
<h1>Just my items</h1>
<%= yield %>
<% parent_layout 'master' %> |
and the parent layout of items – the master layout :
1
2
3
4
5
6
7
|
# master.html.erb
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><title>Hello World</title></head>
<body>
<%= yield %>
</body>
</html> |
Now, the items layout will always be wrapped under the master layout. Just make sure that the parent_layout call is always on the last line using <%. This technique also works for nesting deeper than a single level.
Posted over 2 years back at has_many :bugs, :through => :rails - Home
Don’t think the nested layouts get any simpler in Rails.
1
2
3
4
5
6
|
module ApplicationHelper
def parent_layout(layout)
@content_for_layout = self.output_buffer
self.output_buffer = render(:file => "layouts/#{layout}")
end
end |
Now using the parent_layout helper method inside your layouts for nesting :
1
2
3
4
5
|
# items.html.erb
<h1>Just my items</h1>
<%= yield %>
<% parent_layout 'master' %> |
and the parent layout of items – the master layout :
1
2
3
4
5
6
7
|
# master.html.erb
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><title>Hello World</title></head>
<body>
<%= yield %>
</body>
</html> |
Now, the items layout will always be wrapped under the master layout. Just make sure that the parent_layout call is always on the last line using <%. This technique also works for nesting deeper than a single level.
Posted over 2 years back at Ruby Inside
Why's Markaby is a really convenient bit of Ruby for generating HTML in your applications, rather than having to fiddle about with string interpolation or ERb, tangling together HTML and Ruby.
However, Markaby can be slow compared with other options like Erubis or HAML. Magnus Holm has been working on an alternative solution called Parkaby, which uses ParseTree for improved performance (coming out up to 20 times faster than Markaby in Magnus's tests). Parkaby uses near-identical syntax to Markaby, so you still get to write beautiful ruby code for building your HTML.
Parkaby {
html {
head {
title "happy title"
}
body {
h1 "happy heading"
a "a link", "href" => "url"
}
}
}
Magnus admits that Parkaby is currently only experimental, and that there's room for more optimization, but I think he might be onto something. Parkaby is available on Github.
Posted over 2 years back at GIANT ROBOTS SMASHING INTO OTHER GIANT ROBOTS - Home
It’s been almost a year since we first launched the Toad, so we thought it was time to clean things up a bit. Without further ado, we’d like to announce the newly redesigned Hoptoad!

The look and feel of the entire application has been revamped to provide a more enjoyable experience. We started with a fresh stylesheet, and then unified the form and button styles between our other applications, resulting in a clean and pleasant look throughout.
We used the menu styles from Thunder Thimble, meaning that account, project, and user settings are easily accessible from the entire application.
We cleaned up the errors index so that common tasks, such as viewing all errors for a particular project, are only a click away.
The error info page has been rearranged so that the most important information for each exception is easy to find. Navigating through the details for each error has been made easier by an improved tabbed layout.
Associated Lighthouse tickets show up with number, title, and tags. We moved ticket info into the sidebar to avoid extra clicks between tabs. Adding and finding tickets is easier, too.
We also took this opportunity to make subtle usability changes throughout the application, too numerous to mention here, that should make Hoptoad even easier to use than before.
If you’re a Hoptoad user, just log in to see the new design. You’ll want a Tadpole account or better to take advantage of integration with Lighthouse.
If you’re not using Hoptoad yet, what are you waiting for? You can sign up for free!
Posted over 2 years back at GIANT ROBOTS SMASHING INTO OTHER GIANT ROBOTS - Home
It’s been almost a year since we first launched the Toad, so we thought it was time to clean things up a bit. Without further ado, we’d like to announce the newly redesigned Hoptoad!

The look and feel of the entire application has been revamped to provide a more enjoyable experience. We started with a fresh stylesheet, and then unified the form and button styles between our other applications, resulting in a clean and pleasant look throughout.
We used the menu styles from Thunder Thimble, meaning that account, project, and user settings are easily accessible from the entire application.
We cleaned up the errors index so that common tasks, such as viewing all errors for a particular project, are only a click away.
The error info page has been rearranged so that the most important information for each exception is easy to find. Navigating through the details for each error has been made easier by an improved tabbed layout.
Associated Lighthouse tickets show up with number, title, and tags. We moved ticket info into the sidebar to avoid extra clicks between tabs. Adding and finding tickets is easier, too.
We also took this opportunity to make subtle usability changes throughout the application, too numerous to mention here, that should make Hoptoad even easier to use than before.
If you’re a Hoptoad user, just log in to see the new design. You’ll want a Tadpole account or better to take advantage of integration with Lighthouse.
If you’re not using Hoptoad yet, what are you waiting for? You can sign up for free!