SQLTerminal.app
now available

XPath.app
now available
Want fresh tech tips in your inbox?

Render Partial if File Exists

       

If you ever want to render a partial but don't want an error thrown you can either check for the existence of the file first


<%= render :partial => params[:controller]+"/sidebar" if File.exists?(RAILS_ROOT+"/app/views/"+params[:controller]+"/_sidebar.html.erb") %>

or you can catch the error that Rails throws


<%= render :partial => params[:controller]+"/sidebar" rescue nil %>

Tagged w/ #files #nil #partial #render #rescueprogramming #ruby on rails

Apps I've Built

XPath Expression Editor
Practice and improve your XPath skills with XPath Editor
Click to buy on the App Store
Photo Location Changer
Easily change the location on your photos and videos
Click here for more info about the app
Photo Date Changer
Easily change the dates and times on your photos and videos
Click here for more info about the app
VocabReminder
English dictionary with notifications so you won't forget what you're studying!
Click here for more info about the app
VocabQuiz
The app that quizzes and scores you on your vocabulary!
Click here for more info about the app