This is one example of one entry in my database:
Market id: 1, name: "Independence Park (Independently Run Farmers Market...", address: "3945 N. Springfield Ave., Chicago, IL", zipcode: "60618", created_at: "2013-01-01 21:22:24", updated_at: "2013-01-01 21:22:24"
All I want to do is list the 43 zipcodes from all the entries in my database. Why don't these queries work?
Market.all.each { |m| m.zipcode }
Market.all.zipcode
m = Market.all
m.each{ |m| m.zipcode }
Thanks!
If all you want is an array of zip codes, I would suggest to try this:
Market.pluck(:zipcode)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With