In my application I have a model that is below;
class Init < ActiveRecord::Base
attr_accessor :clientAvailability
attr_accessible :returnCode, :returnMessage, :tokenCode, :updateURL
end
In here when I've added the **attr_accessor** later on and when I try to apply **render json: init** it doesn't show the **clientAvailability** property even though I've set it as;
init=Init.new
init.clientAvailability="3"
When I debug it I can see that it is set, but doesn't simply show up when I try to render it as json. What could be the thing I'm missing?
Is clientAvailability a column in the DB? If not, then I suppose it is the default way - to serialize only the DB attributes. But you can do:
render json: init, methods: [:clientAvailability]
to include clientAvailability attribute.
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