Hi Fred,

Thanks for taking the trouble to respond again, especially since I
failed to follow your previous response.  The problem then was that I
was unsuccessful in applying it or didn't understand it ... probable
both.  I definitely failed to realize that the argument (object) was
to be omitted in the context of form elements.  That "little detail"
seems missing in ActionView::Helpers::FormOptionsHelper.  Someone
explicitly mentioned that in a subsequent post on this thread.

Sadly,  when I followed your suggestion "to the letter", I was
unsuccessful again.  I've got:
====== Error Msg =========
 NameError in Expenses#new

Showing app/views/expenses/new.html.erb where line #13 raised:

undefined local variable or method `vendor_id' for #<ActionView::Base:
0x4822310>

Extracted source (around line #13):

10:
11:     <%# New version of vendor selection -%>
12:     <% @vendors = Vendor.find( :all, :order=>"nickname ASC") -%>
13:     <%= f.collection_select(vendor_id, @vendors, :id, :nickname)
%>
14:     <%# End of New version -%>
[snip]
====== Error Msg =========

So I tested whether vendor_id would be defined if I created an Expense
instance in Rails console: Here's what I got (edited for brevity):
K:\_Projects\Ruby\_Rails_Apps\_EIMS\RTS>ruby script/console
Loading development environment (Rails 2.3.5)
>> expense = Expense.new
=> #<Expense id: nil, vendor: nil, description: nil, category: nil,
[snip]
>> expense.vendor_id [NoMethodError]
>> Expense.vendor_id [NoMethodError]
>> params[:vendor_id] [NameError]

I also tried using the symbol :vendor_id as the first arg.   That
failed, too.

I apologize for being so obtuse.  But I'd really like to get this app
working,  and getting this expense-vendor hookup working may be my
last obstacle (for a while, anyway).

If you can give me a little more help about this problem, I'd be most
appreciative.  If you need more info,  I'd be happy to post portions
or all my code to a website from which you could download it for
inspection.

Best wishes,
Richard


On Jul 17, 5:29 am, Frederick Cheung <frederick.che...@gmail.com>
wrote:
> On Jul 16, 10:40 pm, RichardOnRails
>
> <richarddummymailbox58...@uscomputergurus.com> wrote:
> > Hey Colin,
>
> > Here's one more detail I should have added from my new-expense-view
> > code:
>
> >     <%= f.label :vendor %><br />
>
> >     <%# New version of vendor selection -%>
> >     <% params[:expense] = 10 -%>
> >     <% @vendors = Vendor.find( :all, :order=>"nickname ASC") -%>
> >     <%= f.collection_select(:id, @vendors, :id, :nickname) %>
>
> because the first argument should be the name of the attribute you are
> trying to set (ie vendor_id). This and f.collection_select not needing
> the first argument was on the link I gave on one of your other posts
> (http://guides.rubyonrails.org/form_helpers.html)
>
> Fred
>
> >     <%# End of New version -%>
>
> > I apologize for the fragmented response.  I was in a hurry to go out
> > for my 3-mile walk :-)
>
> > Best again,
> > 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 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.

Reply via email to