是因为我没有安装'digest/sha1'和'digest/md5'么?当代码中有如下语句,需要安装这几个文件么?谢谢各位的帮助!
require 'digest/sha1'
require 'digest/md5'
require 'rubygems'
require 'atom/feed'
#################################################################################################
运行时出现错误500 internal erro,log记录如下:
/app/models/bookmark.rb:20:in initialize'
new'
/app/models/bookmark.rb:20:in
/app/models/bookmark.rb:20:in uri='
send'
C:/INSTAN~1.0-W/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:2117:in
C:/INSTAN~1.0-W/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:2117:in attributes='
each'
C:/INSTAN~1.0-W/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:2116:in
C:/INSTAN~1.0-W/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:2116:in attributes='
initialize'
C:/INSTAN~1.0-W/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1926:in
/app/controllers/bookmarks_controller.rb:37:in new'
create'
/app/controllers/bookmarks_controller.rb:37:in
C:/INSTAN~1.0-W/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1158:in `send'
#################################################################################################
我在模型Bookmark.rb中有如下定义:
def uri=(new_uri)
super
self.uri_hash = Digest::MD5.new(new_uri).to_s (第20行)
end
#################################################################################################
bookmarks_controller代码片断如下:
def create
bookmark = Bookmark.find_by_user_id_and_uri(params[:bookmark][:user_id],
params[:bookmark][:uri])
if bookmark
# This user has already bookmarked this URI. They should be
# using PUT instead.
headers['Location'] = bookmark_url(@user.name, bookmark.uri)
render :nothing => true, :status => "409 Conflict"
else
# Enforce default values for 'timestamp' and 'public'
params[:bookmark][:timestamp] ||= Time.now
params[:bookmark][:public] ||= "1"
# Create the bookmark in the database.
bookmark = Bookmark.new(params[:bookmark]) (第37行)
if bookmark.save
# Add tags.
bookmark.tag_with(params[:taglist]) if params[:taglist]
# Send a 201 response code that points to the location of the
# new bookmark.
headers['Location'] = bookmark_url(@user.name, bookmark.uri)
render :nothing => true, :status => "201 Created"
else
render :xml => bookmark.errors.to_xml, :status => "400 Bad Request"
end
end
end