开发者

Ruby on Rails 3: Updating join table, using 2 parameters?

开发者 https://www.devze.com 2023-04-11 14:37 出处:网络
I have a join table, which have 3 parameters. I want to update it, using a where-clause, something like this: (which obviously is not correct)

I have a join table, which have 3 parameters. I want to update it, using a where-clause, something like this: (which obviously is not correct)

Grid.update(:page_id => @page_id,:thing_id => @thing_id,:number => @number 开发者_C百科).where(:page_id => @page_id, :number => @number ).first

I need to find the record with mathing page_id and number, and then update the thing_id.

Thanks! Jakob


Grid.where(:page_id => @page_id, :number => @number).first.
  update_attributes(:page_id => ...,: thing_id => ..., :number => ...)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号