I have an extremely frustrating problem and I kind of think this is an
error in rails, but you never know.
I have a hash of objects that I am iterating through in order to display
the needed info. As I am doing that and displaying half a dozen values,
one value is being interrupted by rails as a hash and giving me this
error:
I understand what the messages says, it thinks I am working with a hash,
the thing is that I’m not. The column is clearly defined as a character
varying as is most all of the other columns which display with no
problem. The thing is I can’t figure out how to fix this problem. Here
is some of my code:
I notice that the hash displayed in the error have a member amenities
whereas in the line which generates the error it is amen. Is this
part of the problem?
What happens if in a console you type
c = Hotelcontracts.first (or whetever the model is called)
c.amen
Otherwise paste the code from db/schema.rb for this table and the code
for the model.rb (leave out any immaterial methods in there). Also
paste the method from the controller (where presumably @hotelcontracts
is setup).
When I submitted the form that saved all the pertinent info, I had this
code:
@hotelContract.amen = params[:hotelcontract]
which basically took all the hotel contracts fields and saved them into
that one which then got interpreted as a hash. Thanks for the help,
Colin, happy Friday.
I notice that the hash displayed in the error have a member amenities
whereas in the line which generates the error it is amen. Is this
part of the problem?
This is were I think Rails is falling down. Originally I had that field
named as “amenities,” but when the same error was occurring I thought
maybe that was a key word, or something, and changed it to “amen.” But
obviously the problem persists.
What happens if in a console you type
c = Hotelcontracts.first (or whetever the model is called)
c.amen
This produces the same output.
Otherwise paste the code from db/schema.rb for this table and the code
for the model.rb (leave out any immaterial methods in there). Also
paste the method from the controller (where presumably @hotelcontracts
is setup).
Colin
Model:
class Hotelcontract < ActiveRecord::Base
belongs_to :account
end