Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

RUBYʵ¼ù—´øÃÜÂë¼ÓÃܵÄÓû§´´½¨¼°ÐÞ¸Ä

¿ª·¢»·¾³
Ruby: Ruby1.9.1
Rails: Rails2.3.5
Mysql:Mysql5.0.9
Driver:mysql-2.8.1-x86-mingw32.gem
IDE:Rubymine2.0.1
Ò»¡¢´´½¨Êý¾Ý±íUsers
ÀûÓÃRubyMine×Ô´øµÄScaffold¹¤¾ß´´½¨Êý¾Ý±íUsers£¬Ò²¿ÉÒÔÊÖ¶¯´´½¨
¶þ¡¢´´½¨ControllerºÍView
RubyÏîÄ¿—>ÓÒ¼ü—>Create Model
Íê³Éºó½«×Ô¶¯Éú³ÉÏàÓ¦µÄÎļþ
Èý¡¢ÐÞ¸ÄModel user.rb
ÀûÓÃDigest/SHA1¶ÔÃÜÂë½øÐмÓÃÜ£¬ÊµÏÖ¼ÓÃܱ£´æ
Ð޸ĺó´úÂëÈçÏ£º
require "digest/sha1"
class User < ActiveRecord::Base
attr_accessor :hashed_password,:repassword
attr_accessible :username, :hashed_password, :repassword
validates_uniqueness_of :username
validates_presence_of :username, :hashed_password
def before_create
self.password = User.hash_password(self.hashed_password)
end
def after_create
@hashed_password = nil
end
def before_update
self.password = User.hash_password(self.hashed_password)
end
def after_update
@hashed_password = nil
end
private
def self.hash_password(hashed_password)
Digest::SHA1.hexdigest(hashed_password)
end
end
ËÄ¡¢ÐÞ¸Äusers_controller.rb
ÐÞ¸Äupdate·½·¨£¬ÊµÏÖµ±½øÐÐedit²Ù×÷ʱÏÈÅжÏpasswordÓë password_confirmÊÇ·ñÒ»Ö£¬
Èç¹ûÒ»Ö£¬Ôò½øÐÐupdate²Ù×÷£¬·ñÔòÌáʾÓû§password Óë password_confirm ÊäÈë²»Ò»ÖÂ
Ð޸ĺó´úÂëÈçÏ£º
def update
@user = User.find(params[:id])
respond_to do |format|
print "user: #{params[:user]}"
if params[:user]["hashed_password"] == params[:user]["repassword"]
if @user.update_attributes(params[:user])
flash[:notice] = 'User was successfully updated.'
format.html { redirect_to(@user) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
end
else
flash[:notice] = 'Password and Password confirm are not the same'
format.html { render :action => "edit" }
format.xml


Ïà¹ØÎĵµ£º

rubyµÄÀàÓëÄ£¿é£¨1£©

class Point
@x = 1
@y = 2
def initialize(x,y)
@x,@y = x,y
end
end 
´úÂëÖеÄ@x£¬@yΪʵÀý±äÁ¿£¬ÊµÀý±äÁ¿Ö»¶ÔselfµÄ»·¾³Æð×÷Óã¬Òò´ËinitializeÍâÃæµÄ@x=1£¬@y=2Ö»¶ÔÀà±¾ÉíÆð×÷Ó㬶ø·½·¨ÄÚ²¿£¬µÄ@x£¬@yÊǶԶÔÏóµÄʵÀýÆð×÷Óõġ£
class Point
include Enumerable
def initialize(x ......

netbeans + ruby + watir web×Ô¶¯²âÊÔ¿ò¼Ü´î½¨

ÕâÊÇÒ»¸ö¿ªÔ´£¬Ãâ·Ñ£¬ÁéÇÉ£¬¼òÒ×µÄweb×Ô¶¯»¯²âÊÔ×éºÏ¿ò¼Ü£»Í¨³£Çé¿ö£¬¿ªÔ´µÄ¶«Î÷×ÜÊǸøÈËÒÔÃÔÈË£¬¿ª·ÅʽµÄ´¥¸Ð£¬µ«Í¬Ê±£¬Ò²ÈÃÈËÄÑÒÔ¿ìËÙ½Ó½ü£¨ÏñÊǶ«·½ÄÐÈË¿´´ýÎ÷·½ÃÀÅ®£©£»ÒªÁ˽âÒ»¸ö¿ªÔ´¶øÇÒ×éºÏƯÁÁµÄ¿ò¼Ü£¬×ÜÊÇÒª·ÑЩÖÜÕÂ......×ܶøÑÔÖ®£¬Ëü²»»áÏñÊշѵĶ«Î÷£¬ÄãºÜÌÖÑáËü£¬µ«²»¿É·ñÈÏ£¬ÄãµÄ¸¶·ÑÆäʵ»»È¡Á˱ðÈ˵ÄËöËéÀͶ ......

rubyÔÚwindows 7 cmd ÖÐÏÔʾ²ÊÉ«ÎÄ×Ö

ÏÈ·ÅÉÏÒ»¸öʵÀýµÄbatÎļþ,ÒªÇó¹ÜÀíÔ±ÌØȨÔËÐÐ:
@echo off
::CMDÀïÏÔʾ²ÊÉ«ÎÄ×Ö
chcp 437>nul&&graftabl 936>nul
if not exist CONFIG.NT copy %WinDir%\System32\CONFIG.NT CONFIG.NT
@cls
echo DEVICE=%WinDir%\System32\ANSI.SYS /x >%WinDir%\System32\CONFIG.NT
@echo.
command /cecho 
com ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ