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| %> <div id = "contract_<%= @contract.id %>"> <%= @contract.hotel_name %> <%= @contract.rate %> <%= @contract.amen %> ERROR OCCURES HERE </div> <% end %> Has anybody ran into this issue before? And how did you fix it? Thanks, -S -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 4 March 2011 16:10, Shandy Nantz <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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| %> > <div id = "contract_<%= @contract.id %>"> > <%= @contract.hotel_name %> > <%= @contract.rate %> > <%= @contract.amen %> ERROR OCCURES HEREI 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> </div> > <% end %> > > Has anybody ran into this issue before? And how did you fix it? Thanks, > > -S > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> 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.amenThis 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). > > ColinModel: 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. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Looks like your model still has amenities. Paste the result of Hotelcontract.first please.. -Jazmin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.