Rails - Find By with 2 fields?

前端 未结 4 1198
再見小時候
再見小時候 2021-02-01 12:42

I have the following in a controller

def update
    @permission = Permission.find_by_user_id(params[:user_id])

But I want it to also find by a

4条回答
  •  不思量自难忘°
    2021-02-01 12:48

    Try this:

    @permission = Permission.find(:conditions => ['user_id = ? and project_id = ?', params[:user_id], params[:project_id]])
    

提交回复
热议问题