Why when you iterate through a serialized JSON hash but spits out that the class is nil?
View
<% @test.yo.keys.each do |key| %>
<%= key %>
<% end %>
Model
class Test < ActiveRecord::Base
belongs_to :city
serialize :yo, JSON
end
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
it’s saying that yo is nil for @test. you need to check yo for nil before you call a method against it :
you can probably find a better place to put your check, but this gives you an idea of how to fix it