.

How to use an auto_complete to validate passwords

As a follow up to my previous article about using auto_completes to ensure unique filenames, I’ve put together a bit of code that does essentially the same thing except that it checks a password field to ensure that it meets certain criteria.

  1. # view file
  2. <%= text_field_with_auto_complete :user, :password %><div id=login_error></div>
  3.  
  4. # model file
  5.  
  6. def User < ActiveRecord::Base
  7.   validates_length_of :password, :in=>3..20
  8. end
  9.  
  10. # controller file
  11.  
  12. def auto_complete_for_user_password
  13.   @user = User.new(params[:user])
  14.   @user.valid# ensures the errors array is populated
  15.   password_errors = @user.errors.on(‘password’)
  16.   render :update do |page|
  17.      page.replace_html ‘login_error’, (password_errors.empty? ? "" : password_errors)
  18.    end
  19. end

This will indicate when a password does not meet the validation criteria defined in the model. You can add custom validations to check the strength of the password itself.

Using MacFUSE with Rubyforge

I’ve always found it a PITA to administer html files for rubyforge projects, mostly because it requires a lot of command line work to move things around.

Today I started using a new trick. Google has recently released MacFUSE. The neat thing here is that you can also download the sshfs file system and use it to mount an SSH server as a network drive.

Needless to say, this works like a charm with Rubyforge. Just fire up the sshfs.app file after installing the MacFUSE core and the sshfs.app bundle.

It will ask you for a server, type ‘rubyforge.org’. Enter your rubyforge id as well, and for the directory, enter something like

/var/www/gforge-projects/project name/

It will ask you for a password, and then like magic, your rubyforge filespace will be mounted like a drive. Now you have no excuse for not putting some documentation or a spiffy web page up there.

Incidentally, once the connection is established, you can quit the ’sshfs.app’ program. There are also instructions on the Google code web page that tell you how to use this from the command line. The mounted rubyforge.org drive will also be accessible from the command line as ‘/Volumes/rubyforge.org

subversion repositories unavailable

For now, subversion access to my plugins has been disabled. Hopefully this will be resolved shortly and these will become available again.

For now, if you need access, send me an email and I will send you a zip file of the plugin you require.

Thanks,
Kevin

Next Page »