简体   繁体   中英

Update error rails (stack level too deep)

I'm facing a error in rails while updanting a attribute accepted . accepted is a boolean type coloumn.

This is the code:

 def response
if params[:response]
  @invite = Invite.find_by(invited: '2')
  @invite.update(accepted: params[:response])
  render nothing: true
end
end

The trace (sorry for image):

在此处输入图片说明 The error is Stack level is too deep

I guess when you are calling update action and passing params[:response] , somehow it's invoking response action and falling into an infinite loop, which is raising 'stack level too deep' error.

Change response to update_response or something else to fix the problem.

def update_response
  if params[:response]
    @invite = Invite.find_by(invited: '2')
    @invite.update(accepted: params[:response])
    render nothing: true
  end
end

I'll update this answer as soon as I find any explanation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM