Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialEthan Moffat
184 PointsHow can I display different code if my posts table is empty?
I am here because I am trying to display my blog data on the landing page however, I just cleared the testing and now it gives me a NoMethodError. Obviously it's cause the posts table is empty.
I am curious if there is anyway to display static code when the database table is empty.
Ethan Moffat
184 PointsEthan Moffat
184 PointsNevermind, I ended up just doing a simple if statement to check if the database table is empty by doing
Hope this helps others in the future!