Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee committed Apr 2, 2011
2 parents f70452f + 994e476 commit 938a0a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ def muted
def update_in_place
# TODO: Here need to chack permission
klass, field, id = params[:id].split('__')
puts params[:id]

# 验证权限,用户是否有修改制定信息的权限
case klass
when "user" then return if current_user.id.to_s != id
end

object = klass.camelize.constantize.find(id)
if object.update_attributes(field => params[:value])
render :text => object.send(field).to_s
Expand Down
2 changes: 2 additions & 0 deletions app/models/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class Comment
belongs_to :commentable, :polymorphic => true
belongs_to :user

validates_presence_of :body

before_create :fix_commentable_id
def fix_commentable_id
if self.commentable_id.class == "".class
Expand Down

0 comments on commit 938a0a8

Please sign in to comment.