NoMethodError (undefined method `empty?' for #<Event:0x6042e88>):

廉价感情. 提交于 2019-12-01 10:35:18

Rails is based on Rack. Rack can only handle strings. You're rendering an object, not a string.

You probably want something like:

render plain: @counceling_event.to_s

It basically happens because Rack attempts to call #empty? on the body of the response to determine how it should respond to the client.

But since your @counceling_event isn't a string and doesn't respond to empty? it fails.

I'm unsure what you're trying to do by render body: <SOMETHING>. If you're on a Rails app you probably want to render a view instead of content directly from the controller.

If you really want to render from the controller you should consider using render plain: <SOMETHING>.

Hope this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!