Checking for nil in view in Ruby on Rails

后端 未结 5 674
故里飘歌
故里飘歌 2021-01-11 09:41

I\'ve been working with Rails for a while now and one thing I find myself constantly doing is checking to see if some attribute or object is nil in my view code before I dis

5条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-11 10:08

    Your controller is responsible for deciding which view is going to be rendered. If you can verify that your controller will never render this particular view without an item or item_folder then you do not need to check for nil values.

    By can verify I mean that you have tests/specs that check which view is rendered for nil items and item_folders.

提交回复
热议问题