Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
## The form action, in the controller def change_password @admin = Admin.find(params[:id]) if @admin.save @admin.password = params[:password] end end ## The virtual password accessor, in the model def password=(pass) salt = [Array.new(6) {rand(256).chr}.join].pack("m").chomp self.salt = salt self.password_hash = Digest::SHA256.hexdigest(pass + salt) end ## Parameters Parameters: {"commit"=>"Change", "admin"=>{"password_confirmation"=>"test", "password"=>"test"}, "id"=>"5"}
From the Design Piracy series on my blog: