!map:HashWithIndifferentAccess

Hi All,

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:

— !map:HashWithIndifferentAccess comm: “1” comm_percentage: “12”
hotel_name: “111947” rate: “2.00” additional_email_1: “” amenities: cccc
neg_by: Client comm_dollar_amt: “34.00” hod: test rac: xxx billing: “0”

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:

<% @hotelcontracts.each do |@contract| %>

"> <%= @contract.hotel_name %> <%= @contract.rate %> <%= @contract.amen %> ERROR OCCURES HERE
<% end %>

Has anybody ran into this issue before? And how did you fix it? Thanks,

-S

On 4 March 2011 16:10, Shandy N. [email protected] wrote:

— !map:HashWithIndifferentAccess comm: “1” comm_percentage: “12”

"> <%= @contract.hotel_name %> <%= @contract.rate %> <%= @contract.amen %> ERROR OCCURES HERE

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).

Colin

Looks like your model still has amenities.

Paste the result of Hotelcontract.first please…

-Jazmin

My bad,

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.

-S

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

Controller:
@hotelcontracts = Hotelcontract.find( :all, :conditions => [‘account_id
= ?’, @account.id])

db:
amen is simply defined as a character varying with nothing really
different then any of the other fields in the table.

-S

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs