Use query attribute (Rails)

Use query attribute (Rails)
Bad Smell
< if @user.login.blank? >    <= link_to 'login', new_session_path >< end >< if @user.login.present? >    <= @user.login >< end >It's not bad, but rails provides a cleaner way, we should use query attributes to make codes simpler


Refactor

< unless @user.login? >    <= link_to 'login', new_session_path >< end >< if @user.login? >    <= @user.login >< end >

你可能感兴趣的:(Rails)