我已經在我的控制器下面的附件的Rails 3 - 慘慘 - 定義一個權限創建
def upload
@attachment = Attachment.build(:swf_uploaded_data => params[:attachment][:attachment], :user_id => current_user.id, :project_id => params[:space_id])
....
end
我從康康舞喜歡的是隻允許用戶上傳他們屬於一個PROJECT_ID。我證實了該控制器是獲得正確的信息,沒有尼爾斯
這是我的康康舞:這裏
can :upload, Attachment do |attachment|
Rails.logger.info 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX- include CanCan::Ability - ATTACHMENT'
Rails.logger.info attachment.inspect
Rails.logger.info attachment.project
current_user.try(:role, attachment.space)
end
問題,就是附件。是零,並且attachment.project是零?您如何解決CanCan的這個問題,以確保只有項目團隊成員可以將附件上傳到項目中?
謝謝