Hey Fred, Thanks for you additional guidance on my introduction of belongs_to, etc.
> <[email protected]> wrote: > > > Assuming Vendor belongs_to :expense then > > > f.collection_select :vendor_id, @vendors, :id, :name > > > would do the trick > > > Au contraire: My concept is that every Expense belongs to some > > Vendor. However, every Vendor can have many different Expenses > > (incurred, as it were, at various times). > > Sorry I worded that one back to front No problem: I make so many mistakes that I amazed I get anything to work. > > That gave me: > > undefined method `merge' for :nickname:Symbol (referencing the > > collection_select line) > > It's getting confused because ... I coded a corrected (I hope) version in app\views\expenses \new.html.erb: <p> <%= f.label :vendor %><br /> <%# New version of vendor selection -%> <% @vendors = Vendor.find( :all, :order=>"nickname ASC") -%> <%= f.collection_select(:vendor, @vendors, :id, :nickname) %> <%# End of New version -%> <%= link_to 'New Vendor', :controller=>'vendors', :action=>'new' %> </p> I got the following error msgs which I suspect are due to the fact that I added one-to-many, etc after I already had a running version that saved the vendor-name in the expense record. ActiveRecord::AssociationTypeMismatch in ExpensesController#create Vendor(#37938940) expected, got String(#21132310) [snip] K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/base.rb:2438:in `initialize' K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS/app/controllers/ expenses_controller.rb:44:in `new' K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS/app/controllers/ expenses_controller.rb:44:in `create' Request Parameters: {"commit"=>"Create", "expense"=>{"category"=>"junk", "account"=>"the account", "mode"=>"check", "tran_date(1i)"=>"2010", "tran_date(2i)"=>"7", "description"=>"7/13-1227 attempt", "amount"=>"123.45", "tran_date(3i)"=>"13", "vendor"=>"65", "user_id"=>"rlm"}, "authenticity_token"=>"d7GwyUWfO8eyfwkiEbquQ4SQZr+zf4UQNJ4h6LxVDmE="} Expense Controller, expenses_controller.rb, lines 43-44 are: def create @expense = K:\_Projects\Ruby\_Rails_Apps\_EIMS\RTS\app\controllers \Expense.new(params[:expense]) Can you suggest how this should be coded in light of the vendor- expenses linkage? Thanks again in advance for any guidance you have time to offer. Best wishes, Richard -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

