Firstly have I asked before? Please do not top post, it makes it much easier to follow the thread if you insert your comments at appropriate points in the previous post. Thanks.
On 18 July 2010 04:08, RichardOnRails <richarddummymailbox58...@uscomputergurus.com> wrote: > Well, I don't see anything wrong. stmt 44 in Expense controller > creates new Expense instance passing it the content of the :expense > item in the params hash, which is displayed in detail in the crash > output. Please post that bit of code and a few lines around it, indicate which is that line please. > > The :expense item is itself a hash of all the values enter in the New > Expense form. In particular, the vendor string key has the value > string 65, which is indeed the vendor I select from the drop-down. I cannot see the hash in the trace that you posted. Am I right in understanding that in there you have an expense hash and that within that you have a vendor field containing the string "65". You say that you are constructing a new expense instance giving it the expense hash. Rails will see in there the vendor value ("65") and assume that you are trying to set the vendor field of the expense to 65. I am assuming now that the expense table does not have a field called vendor, but that you have expense belongs_to vendor. It therefore expects to find a vendor object in the hash and instead finds a string. Hence the error message. Does that make sense? Is it possibly expense.vendor_id that you are trying to set to 65, assuming that the table has a vendor_id column. Colin -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.