简体   繁体   English

视图中的Rails Twitter Gem 404错误处理

[英]Rails Twitter Gem 404 Error Handling in the view

I have this line in my view file: 我的视图文件中包含以下行:

- tweets = Twitter.user_timeline(@organization.twitter_name)

The attr twitter_name is entered by the user. attr twitter_name由用户输入。 If they enter an invalid twitter account name, it throws a 404 error. 如果他们输入了无效的Twitter帐户名,则会引发404错误。

How can I deal with the error to avoid getting this action controller exception? 我该如何处理错误以避免此操作控制器异常? Twitter::NotFound in Organizations#show

您可以使用rescue来捕获异常并显示用户友好的错误消息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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