Hi, I''ve got a Rails app working that includes two two classes, etc.: Expense & Vendor. I eventually learned that the mental concept I had of their relationship should be express in Rails as: class Expense < ActiveRecord::Base; belongs_to :vendor; end class Vendor < ActiveRecord::Base; has_many :expenses; end http://rails.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html informs me that the following methods will be generated in Expense: vendor vendorvendor.nil 1. Are my expectations correct? 2. What do I have to do to get them generated? (I can''t find any such methods defined anywhere.) Thanks in Advance, 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-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.
Frederick Cheung
2010-Jul-16 14:46 UTC
Re: Added associations but don''t see generated methods
On Jul 16, 3:32 pm, RichardOnRails <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> wrote:> Hi, > > I''ve got a Rails app working that includes two two classes, etc.: > Expense & Vendor. I eventually learned that the mental concept I had > of their relationship should be express in Rails as: > > class Expense < ActiveRecord::Base; belongs_to :vendor; end > class Vendor < ActiveRecord::Base; has_many :expenses; end > > http://rails.rubyonrails.org/classes/ActiveRecord/Associations/ClassM... > informs me that the following methods will be generated in Expense: > > vendor > vendor> vendor.nil > > 1. Are my expectations correct?yes (and there are some other methods too)> 2. What do I have to do to get them generated? (I can''t find any such > methods defined anywhere.)what makes you think they aren''t there ? Fred -- 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.
Hi Richard, On Fri, Jul 16, 2010 at 9:32 AM, RichardOnRails wrote:>> http://rails.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html > informs me that the following methods will be generated in Expense: > > vendor > vendor> vendor.nil > > 1. Are my expectations correct? > 2. What do I have to do to get them generated? (I can''t find any such > methods defined anywhere.)In the Rails console, try these: Expense.methods Expense.public_methods Expense.private_methods One of the things that takes some getting used to with Rails is how much it does a lot for you behind the scenes. HTH, Bill -- 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.
RichardOnRails
2010-Jul-16 15:10 UTC
Re: Added associations but don''t see generated methods
Hi Fred, Thanks for your timely response.> what makes you think they aren''t there ?I searched for them to no avail. Shouldn''t they be in the Expense model (app\models\expense.rb); or Expense controller (app\controllers\expenses_controller.rb? I made a case-insensitive search for /vendor.nil\?/ in every application file whose name matched /e?rb/i to no avail. Could it be that adding relationships after the app & the database have been created doesn''t work? Would I have better luck if I scrapped everything and recreated the app with the relationships defined? IMHO, that would substantially limit the usefulness of relationship macros. Thanks again, Richard On Jul 16, 10:46 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jul 16, 3:32 pm, RichardOnRails > > > > <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> wrote: > > Hi, > > > I''ve got a Rails app working that includes two two classes, etc.: > > Expense & Vendor. I eventually learned that the mental concept I had > > of their relationship should be express in Rails as: > > > class Expense < ActiveRecord::Base; belongs_to :vendor; end > > class Vendor < ActiveRecord::Base; has_many :expenses; end > > >http://rails.rubyonrails.org/classes/ActiveRecord/Associations/ClassM... > > informs me that the following methods will be generated in Expense: > > > vendor > > vendor> > vendor.nil > > > 1. Are my expectations correct? > > yes (and there are some other methods too)> 2. What do I have to do to get them generated? (I can''t find any such > > methods defined anywhere.) > > what makes you think they aren''t there ? > > Fred-- 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.
Andy Jeffries
2010-Jul-16 15:18 UTC
Re: Re: Added associations but don''t see generated methods
> > > what makes you think they aren''t there ? > > I searched for them to no avail. Shouldn''t they be in the > Expense model (app\models\expense.rb); or > Expense controller (app\controllers\expenses_controller.rb? >No, they are dynamically defined and exist in memory only at runtime. Welcome to dynamic objects and classes :-) Try using script/console to execute them. Cheers, Andy -- 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.
RichardOnRails
2010-Jul-16 15:50 UTC
Re: Added associations but don''t see generated methods
Hi Andy,>> expense = Expense.find(1)=> #<Expense id: 1, vendor: "Z01-2010.06.26 (Z01-Test)", [snip]>> expense.vendor.nil?=> true>> quit> Welcome to dynamic objects and classes :-)Thanks. This restores my faith in Rails and enhances my appreciation of newsgroups, especially this one. Now I''ve got to put them to use! Best wishes, Richard On Jul 16, 11:18 am, Andy Jeffries <a...-4Fjv1yF9AWJvmwGHilWZ5bVCufUGDwFn@public.gmane.org> wrote:> > > what makes you think they aren''t there ? > > > I searched for them to no avail. Shouldn''t they be in the > > Expense model (app\models\expense.rb); or > > Expense controller (app\controllers\expenses_controller.rb? > > No, they are dynamically defined and exist in memory only at runtime. > Welcome to dynamic objects and classes :-) > > Try using script/console to execute them. > > Cheers, > > Andy-- 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.
Andy Jeffries
2010-Jul-16 15:58 UTC
Re: Re: Added associations but don''t see generated methods
> > > Welcome to dynamic objects and classes :-) > Thanks. This restores my faith in Rails and enhances my appreciation > of newsgroups, especially this one. > Now I''ve got to put them to use! >Good luck. Post back if you have any more problems. Cheers, Andy -- 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.
RichardOnRails
2010-Jul-16 19:31 UTC
Re: Added associations but don''t see generated methods
> Post back if you have any more problems.Thanks for your generous offer. So here''s my last (I hope) stumbling block. I got: NoMethodError in Expenses#new Showing app/views/expenses/new.html.erb where line #14 raised: undefined method `merge'' for :nickname:Symbol Extracted source (around line #14): 11: <%# New version of vendor selection -%> 12: <% params[:expense] = 10 -%> 13: <% @vendors = Vendor.find( :all, :order=>"nickname ASC") -%> 14: <%= f.collection_select(:vendor, :id, @vendors, :id, :nickname) %> 15: <%# End of New version -%> 16: 17: <%#= f.collection_select(:vendor, @vendors, :id, :nickname) %> But the claim about nickname being bogus seems suspicious to me. For one thing:>> Vendor.find(:first)=> #<Vendor id: 62, nickname: "vendor 5/15/2010", qbname: "Test new field names", [snip] And the arguments seem to agree with http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html, particularly the guidance for the public instant method: collection_select(object, method, collection, value_method, text_method, options = {}, html_options = {}) Any ideas? Thanks in Advance, Richard On Jul 16, 11:58 am, Andy Jeffries <a...-4Fjv1yF9AWJvmwGHilWZ5bVCufUGDwFn@public.gmane.org> wrote:> > > Welcome to dynamic objects and classes :-) > > Thanks. This restores my faith in Rails and enhances my appreciation > > of newsgroups, especially this one. > > Now I''ve got to put them to use! > > Good luck. > > Post back if you have any more problems. > > Cheers, > > Andy-- 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.
Colin Law
2010-Jul-16 19:39 UTC
Re: Re: Added associations but don''t see generated methods
On 16 July 2010 20:31, RichardOnRails <RichardDummyMailbox58407-gP6xRNRnnqSxhq/XJNNIW0EOCMrvLtNR@public.gmane.org> wrote:>> Post back if you have any more problems. > Thanks for your generous offer. So here''s my last (I hope) stumbling > block. I got: > > NoMethodError in Expenses#new > > Showing app/views/expenses/new.html.erb where line #14 raised: > > undefined method `merge'' for :nickname:Symbol > > Extracted source (around line #14): > > 11: <%# New version of vendor selection -%> > 12: <% params[:expense] = 10 -%> > 13: <% @vendors = Vendor.find( :all, :order=>"nickname ASC") -%> > 14: <%= f.collection_select(:vendor, :id, > @vendors, :id, :nickname) %> > 15: <%# End of New version -%> > 16: > 17: <%#= f.collection_select(:vendor, @vendors, :id, :nickname) %> > > But the claim about nickname being bogus seems suspicious to me. For > one thing: > >>> Vendor.find(:first) > => #<Vendor id: 62, nickname: "vendor 5/15/2010", qbname: "Test new > field names", [snip] > > And the arguments seem to agree with > http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html, > particularly the guidance for the public instant method: > > collection_select(object, method, collection, value_method, > text_method, options = {}, html_options = {})If you use collection_select on its own you need to pass the object, but f.collection_select inside a form_for takes the object from form_for. The documentation is a bit confusing in that area. Colin> > Any ideas? > > Thanks in Advance, > Richard > > > On Jul 16, 11:58 am, Andy Jeffries <a...-4Fjv1yF9AWJvmwGHilWZ5bVCufUGDwFn@public.gmane.org> wrote: >> > > Welcome to dynamic objects and classes :-) >> > Thanks. This restores my faith in Rails and enhances my appreciation >> > of newsgroups, especially this one. >> > Now I''ve got to put them to use! >> >> Good luck. >> >> Post back if you have any more problems. >> >> Cheers, >> >> Andy > > -- > 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.
RichardOnRails
2010-Jul-16 21:07 UTC
Re: Added associations but don''t see generated methods
Hi Bill, I didn''t notice your response a while ago. I did try out all three "method" displays. They all returned a slew of methods, even the most restrictive one, private_methods. One of the strangest results to me is:>> expense = Expense.find(:first)=> #<Expense id: 1, vendor: "Z01-2010.06.26 (Z01-Test)", description: "Added new vendor", [snip]>> expense.vendor=> nil Clearly the vendor attribute of the first expense record in not nil, as expense.vendor reports BTW, the vendor attribute represents the (artificial vendor name) rather than a vendor id because I''ve got another problem, which I reported in one of the other posts on this thread. Thanks for weighing in here about my problem. Things are looking up. Best wishes, Richard On Jul 16, 11:06 am, Bill Walton <bwalton...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Richard, > > On Fri, Jul 16, 2010 at 9:32 AM, RichardOnRails wrote:> > >http://rails.rubyonrails.org/classes/ActiveRecord/Associations/ClassM... > > informs me that the following methods will be generated in Expense: > > > vendor > > vendor> > vendor.nil > > > 1. Are my expectations correct? > > 2. What do I have to do to get them generated? (I can''t find any such > > methods defined anywhere.) > > In the Rails console, try these: > > Expense.methods > Expense.public_methods > Expense.private_methods > > One of the things that takes some getting used to with Rails is how > much it does a lot for you behind the scenes. > > HTH, > Bill-- 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.
RichardOnRails
2010-Jul-16 21:31 UTC
Re: Added associations but don''t see generated methods
Hey Colin,> If you use collection_select on its own you need to pass the object, > but f.collection_select inside a form_for takes the object from > form_for.Awesome insight! Thanks. I''ve been trying for days to dig myself out of this blunder. Idle question: Do you know whether that distinction is actually mentioned somewhere? I''ll search for it in http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html Serious question. I deleted the first argument (the object) and ran the app successfully: 1. created a new expense 2. created a new vendor for this expense 3. selected the new vendor from the drop-down list 4. saved the expense The problem: The vendor field of the expense record is nil.. I expected a vendor_id there! I need one last (I hope) idea. Some details below Thanks in advance, Richard . On Jul 16, 3:39 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 16 July 2010 20:31, RichardOnRails > > > > <RichardDummyMailbox58...-gP6xRNRnnqSxhq/XJNNIW0EOCMrvLtNR@public.gmane.org> wrote: > >> Post back if you have any more problems. > > Thanks for your generous offer. So here''s my last (I hope) stumbling > > block. I got: > > > NoMethodError in Expenses#new > > > Showing app/views/expenses/new.html.erb where line #14 raised: > > > undefined method `merge'' for :nickname:Symbol > > > Extracted source (around line #14): > > > 11: <%# New version of vendor selection -%> > > 12: <% params[:expense] = 10 -%> > > 13: <% @vendors = Vendor.find( :all, :order=>"nickname ASC") -%> > > 14: <%= f.collection_select(:vendor, :id, > > @vendors, :id, :nickname) %> > > 15: <%# End of New version -%> > > 16: > > 17: <%#= f.collection_select(:vendor, @vendors, :id, :nickname) %> > > > But the claim about nickname being bogus seems suspicious to me. For > > one thing: > > >>> Vendor.find(:first) > > => #<Vendor id: 62, nickname: "vendor 5/15/2010", qbname: "Test new > > field names", [snip] > > > And the arguments seem to agree with > >http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelp..., > > particularly the guidance for the public instant method: > > > collection_select(object, method, collection, value_method, > > text_method, options = {}, html_options = {}) > > If you use collection_select on its own you need to pass the object, > but f.collection_select inside a form_for takes the object from > form_for. > > The documentation is a bit confusing in that area. > > Colin > > > > > Any ideas? > > > Thanks in Advance, > > Richard > > > On Jul 16, 11:58 am, Andy Jeffries <a...-4Fjv1yF9AWJvmwGHilWZ5bVCufUGDwFn@public.gmane.org> wrote: > >> > > Welcome to dynamic objects and classes :-) > >> > Thanks. This restores my faith in Rails and enhances my appreciation > >> > of newsgroups, especially this one. > >> > Now I''ve got to put them to use! > > >> Good luck. > > >> Post back if you have any more problems. > > >> Cheers, > > >> Andy > > > -- > > 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 athttp://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.
RichardOnRails
2010-Jul-16 21:36 UTC
Re: Added associations but don''t see generated methods
Here are the details I intended to add to my last post:>> expense = Expense.find(:last)=> #<Expense id: 5, vendor: nil, description: "Chose vendor 5/21/2010", category: "cat", account: "act", [snip] 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 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.
RichardOnRails
2010-Jul-16 21:40 UTC
Re: Added associations but don''t see generated methods
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) %> <%# 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-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.
Frederick Cheung
2010-Jul-17 09:29 UTC
Re: Added associations but don''t see generated methods
On Jul 16, 10:40 pm, RichardOnRails <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> 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-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.
RichardOnRails
2010-Jul-17 13:24 UTC
Re: Added associations but don''t see generated methods
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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jul 16, 10:40 pm, RichardOnRails > > <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> 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-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.
RichardOnRails
2010-Jul-17 14:50 UTC
Re: Added associations but don''t see generated methods
Hi All, I got closer. I tried: <% @vendors = Vendor.find( :all, :order=>"nickname ASC") -%> <%= f.collection_select(:vendor, @vendors, :id, :nickname) %> I ran the app and created a new expense. I clicked the drop-down list, selected a vendor, populated the remaining fields of the form and saved the expense. The app then crashed (that''s the bad part), *but* the Request parameters were perfect, specifically: "vendor"=>"64" So I saw the selected vendor''s name when I clicked Save/Submit/ whatever and the generated expense record contained the id of the selected vendor, not the name of that vendor, as had been the case in some earlier versions of my code. Below are some details of this crash. Thanks for any help you may offer in resolving this matter. -- Richard ActiveRecord::AssociationTypeMismatch in ExpensesController#create Vendor(#37038620) expected, got String(#21132310) RAILS_ROOT: K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS Application Trace | Framework Trace | Full Trace K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/associations/association_proxy.rb: 262:in `raise_on_type_mismatch'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/associations/ belongs_to_association.rb:22:in `replace'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/associations.rb:1281:in `vendor='' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/base.rb:2746:in `send'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/base.rb:2746:in `attributes='' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/base.rb:2742:in `each'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/base.rb:2742:in `attributes='' 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'' On Jul 17, 9:24 am, RichardOnRails <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> wrote:> 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > On Jul 16, 10:40 pm, RichardOnRails > > > <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> 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-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.
Colin Law
2010-Jul-17 20:33 UTC
Re: Re: Added associations but don''t see generated methods
On 17 July 2010 15:50, RichardOnRails <RichardDummyMailbox58407-gP6xRNRnnqSxhq/XJNNIW0EOCMrvLtNR@public.gmane.org> wrote:> Hi All, > > I got closer. I tried: > > <% @vendors = Vendor.find( :all, :order=>"nickname ASC") -%> > <%= f.collection_select(:vendor, @vendors, :id, :nickname) %> > > I ran the app and created a new expense. I clicked the drop-down list, > selected a vendor, populated the remaining fields of the form and > saved the expense. The app then crashed (that''s the bad part), *but* > the Request parameters were perfect, specifically: > "vendor"=>"64" > > So I saw the selected vendor''s name when I clicked Save/Submit/ > whatever and the generated expense record contained the id of the > selected vendor, not the name of that vendor, as had been the case in > some earlier versions of my code. > > Below are some details of this crash. > > Thanks for any help you may offer in resolving this matter. > -- > Richard > > ActiveRecord::AssociationTypeMismatch in ExpensesController#create > > Vendor(#37038620) expected, got String(#21132310)It is always worth while trying to understand error messages, quite often they can give you a clue as the problem. The error above says that a Vendor object was expected, but you have given it a string. From the trace below you can see that it is at line 44 of expenses_controller.rb. Have a look at that line and see if you can work out why it is expecting a Vendor object, see what you have actually provided and see if you understand what is going on. Colin> > RAILS_ROOT: K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS > Application Trace | Framework Trace | Full Trace > > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/associations/association_proxy.rb: > 262:in `raise_on_type_mismatch'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/associations/ > belongs_to_association.rb:22:in `replace'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/associations.rb:1281:in `vendor='' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/base.rb:2746:in `send'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/base.rb:2746:in `attributes='' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/base.rb:2742:in `each'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/base.rb:2742:in `attributes='' > 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'' > > > > > On Jul 17, 9:24 am, RichardOnRails > <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> wrote: >> 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> wrote: >> >> > On Jul 16, 10:40 pm, RichardOnRails >> >> > <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> 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-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.
RichardOnRails
2010-Jul-18 03:08 UTC
Re: Added associations but don''t see generated methods
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. 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 restarted Mongrel with the --debugger argument, and Mongrel confirmed that the debugger is enabled. I then put a debugger statement immediately ahead of the offending statement, which thus became line# 45. However, when I refreshed the program in Firefox, the crash output still claimed that it crashed on line 44 (the debugger statement). But the command widow where I started Mongrel seemed to indicated that the app was stopped on line 45. I issues "p params" in the command window and got the same display (except less neatly) as the hash I got in the crash dump. Give all that, I still have no idea why the app crashed. Do you have any idea? Best wishes, Richard On Jul 17, 4:33 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 17 July 2010 15:50, RichardOnRails > > > > <RichardDummyMailbox58...-gP6xRNRnnqSxhq/XJNNIW0EOCMrvLtNR@public.gmane.org> wrote: > > Hi All, > > > I got closer. I tried: > > > <% @vendors = Vendor.find( :all, :order=>"nickname ASC") -%> > > <%= f.collection_select(:vendor, @vendors, :id, :nickname) %> > > > I ran the app and created a new expense. I clicked the drop-down list, > > selected a vendor, populated the remaining fields of the form and > > saved the expense. The app then crashed (that''s the bad part), *but* > > the Request parameters were perfect, specifically: > > "vendor"=>"64" > > > So I saw the selected vendor''s name when I clicked Save/Submit/ > > whatever and the generated expense record contained the id of the > > selected vendor, not the name of that vendor, as had been the case in > > some earlier versions of my code. > > > Below are some details of this crash. > > > Thanks for any help you may offer in resolving this matter. > > -- > > Richard > > > ActiveRecord::AssociationTypeMismatch in ExpensesController#create > > > Vendor(#37038620) expected, got String(#21132310) > > It is always worth while trying to understand error messages, quite > often they can give you a clue as the problem. The error above says > that a Vendor object was expected, but you have given it a string. > From the trace below you can see that it is at line 44 of > expenses_controller.rb. Have a look at that line and see if you can > work out why it is expecting a Vendor object, see what you have > actually provided and see if you understand what is going on. > > Colin > > > > > RAILS_ROOT: K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS > > Application Trace | Framework Trace | Full Trace > > > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > > activerecord-2.3.5/lib/active_record/associations/association_proxy.rb: > > 262:in `raise_on_type_mismatch'' > > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > > activerecord-2.3.5/lib/active_record/associations/ > > belongs_to_association.rb:22:in `replace'' > > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > > activerecord-2.3.5/lib/active_record/associations.rb:1281:in `vendor='' > > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > > activerecord-2.3.5/lib/active_record/base.rb:2746:in `send'' > > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > > activerecord-2.3.5/lib/active_record/base.rb:2746:in `attributes='' > > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > > activerecord-2.3.5/lib/active_record/base.rb:2742:in `each'' > > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > > activerecord-2.3.5/lib/active_record/base.rb:2742:in `attributes='' > > 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'' > > > On Jul 17, 9:24 am, RichardOnRails > > <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> wrote: > >> 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > >> wrote: > > >> > On Jul 16, 10:40 pm, RichardOnRails > > >> > <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> 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-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 athttp://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.
Colin Law
2010-Jul-18 07:48 UTC
Re: Re: Added associations but don''t see generated methods
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 <RichardDummyMailbox58407-gP6xRNRnnqSxhq/XJNNIW0EOCMrvLtNR@public.gmane.org> 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-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.
Frederick Cheung
2010-Jul-18 08:17 UTC
Re: Re: Added associations but don''t see generated methods
On 17 Jul 2010, at 14:24, RichardOnRails <RichardDummyMailbox58407-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> wrote:> 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. >It''s definitely in the form helpers guide - well worth reading (there''s also a section on collection_select and association type mismatch errors)> I also tried using the symbol :vendor_id as the first arg. That > failed, too. >That''s what you should be doing - how did it fail? Fred> 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> On Jul 16, 10:40 pm, RichardOnRails >> >> <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> 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-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. >-- 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.
RichardOnRails
2010-Jul-18 12:22 UTC
Re: Added associations but don''t see generated methods
Hi Fred, I posted four files for easier viewing, I will also post details below, though I find reading them unattractive. The code in question (I thought) was in app\views\expenses \new.html.erb, specifically the lines: <%# New version of vendor selection -%> <% @vendors = Vendor.find( :all, :order=>"nickname ASC") -%> <%= f.collection_select(:vendor_id, @vendors, :id, :nickname) %> <%# NOTE: first argument, symbol :vendor, does not produce an error here either -%> <%# End of New version -%> You may download the file in its entirety from http://www.filefactory.com/file/b29d79e/n/new.html.erb However, the output from the crash indicates the failure was in line 44 of the controller, app\controllers\expenses_controller.rb The code in the neighborhood around line 44 is: # GET /expenses/1/edit def edit @expense = Expense.find(params[:id]) end # POST /expenses # POST /expenses.xml def create debugger # <== Line 44 @expense = Expense.new(params[:expense]) respond_to do |format| if @expense.save flash[:notice] = ''Expense was successfully created.'' format.html { redirect_to(@expense) } format.xml { render :xml => @expense, :status => :created, :location => @expense } Apparently, the crash display-logic doesn''t think the "debugger" line merits a line number. You can download the controller in its entirety from: http://www.filefactory.com/file/b3e9b86/n/expenses_controller.rb The dump from the crash is shown below. It strikes me as fairly ugly, so I did screen captures which may be download from: http://www.filefactory.com/file/b29d409/n/Z15-LowerPart.jpg http://www.filefactory.com/file/b29d3h0/n/Z14-UpperPart.jpg (My screen-capture utility doesn''t support scrolling, so I had to take two images.) Incidentally, the crash dump includes a display of params[:expense], which includes "vendor"=>"65". That''s what I''ve been trying to get, i.e. the vendor field is now populated with the vendor::id of the vendor I selected in the drop-down, rather than the vendor:nickname that I used to get. Hooray!! I hope you can define a cause for my current crash. I can''t. Best wishes, Richard ActiveRecord::AssociationTypeMismatch in ExpensesController#create Vendor(#37410590) expected, got String(#21132310) RAILS_ROOT: K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS Application Trace | Framework Trace | Full Trace K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/associations/association_proxy.rb: 262:in `raise_on_type_mismatch'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/associations/ belongs_to_association.rb:22:in `replace'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/associations.rb:1281:in `vendor='' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/base.rb:2746:in `send'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/base.rb:2746:in `attributes='' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/base.rb:2742:in `each'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/base.rb:2742:in `attributes='' 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'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/associations/association_proxy.rb: 262:in `raise_on_type_mismatch'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/associations/ belongs_to_association.rb:22:in `replace'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/associations.rb:1281:in `vendor='' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/base.rb:2746:in `send'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/base.rb:2746:in `attributes='' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/base.rb:2742:in `each'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/base.rb:2742:in `attributes='' 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:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:1331:in `send'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:1331:in `perform_action_without_filters'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/filters.rb:617:in `call_filters'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:10:in `realtime'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/flash.rb:146:in `perform_action'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:532:in `send'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:532:in `process_without_filters'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/filters.rb:606:in `process'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:391:in `process'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:386:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/routing/route_set.rb:437:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/dispatcher.rb:87:in `dispatch'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/dispatcher.rb:121:in `_call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/dispatcher.rb:130:in `build_middleware_stack'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/query_cache.rb:29:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/query_cache.rb:29:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/connection_adapters/abstract/ query_cache.rb:34:in `cache'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/query_cache.rb:9:in `cache'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/query_cache.rb:28:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/connection_adapters/abstract/ connection_pool.rb:361:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/string_coercion.rb:25:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/head.rb:9:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/methodoverride.rb:24:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/params_parser.rb:15:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/session/cookie_store.rb:93:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/failsafe.rb:26:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/lock.rb:11:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/lock.rb:11:in `synchronize'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/lock.rb:11:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/dispatcher.rb:114:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/reloader.rb:34:in `run'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/dispatcher.rb:108:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/ lib/rails/rack/static.rb:31:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/urlmap.rb:46:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/urlmap.rb:40:in `each'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/urlmap.rb:40:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/ lib/rails/rack/debugger.rb:19:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/ lib/rails/rack/log_tailer.rb:17:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/content_length.rb:13:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/chunked.rb:15:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/handler/mongrel.rb:64:in `process'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:159:in `process_client'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:158:in `each'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:158:in `process_client'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:285:in `run'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:285:in `initialize'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:285:in `new'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:285:in `run'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:268:in `initialize'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:268:in `new'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:268:in `run'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/handler/mongrel.rb:34:in `run'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/ lib/commands/server.rb:111 K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:31:in `gem_original_require'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:31:in `require'' script/server:3 K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/associations/association_proxy.rb: 262:in `raise_on_type_mismatch'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/associations/ belongs_to_association.rb:22:in `replace'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/associations.rb:1281:in `vendor='' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/base.rb:2746:in `send'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/base.rb:2746:in `attributes='' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/base.rb:2742:in `each'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/base.rb:2742:in `attributes='' 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'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:1331:in `send'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:1331:in `perform_action_without_filters'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/filters.rb:617:in `call_filters'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:10:in `realtime'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/flash.rb:146:in `perform_action'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:532:in `send'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:532:in `process_without_filters'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/filters.rb:606:in `process'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:391:in `process'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:386:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/routing/route_set.rb:437:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/dispatcher.rb:87:in `dispatch'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/dispatcher.rb:121:in `_call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/dispatcher.rb:130:in `build_middleware_stack'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/query_cache.rb:29:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/query_cache.rb:29:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/connection_adapters/abstract/ query_cache.rb:34:in `cache'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/query_cache.rb:9:in `cache'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/query_cache.rb:28:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/connection_adapters/abstract/ connection_pool.rb:361:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/string_coercion.rb:25:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/head.rb:9:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/methodoverride.rb:24:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/params_parser.rb:15:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/session/cookie_store.rb:93:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/failsafe.rb:26:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/lock.rb:11:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/lock.rb:11:in `synchronize'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/lock.rb:11:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/dispatcher.rb:114:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/reloader.rb:34:in `run'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/dispatcher.rb:108:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/ lib/rails/rack/static.rb:31:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/urlmap.rb:46:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/urlmap.rb:40:in `each'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/urlmap.rb:40:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/ lib/rails/rack/debugger.rb:19:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/ lib/rails/rack/log_tailer.rb:17:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/content_length.rb:13:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/chunked.rb:15:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/handler/mongrel.rb:64:in `process'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:159:in `process_client'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:158:in `each'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:158:in `process_client'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:285:in `run'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:285:in `initialize'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:285:in `new'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:285:in `run'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:268:in `initialize'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:268:in `new'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:268:in `run'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/handler/mongrel.rb:34:in `run'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/ lib/commands/server.rb:111 K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:31:in `gem_original_require'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:31:in `require'' script/server:3 Request Parameters: {"commit"=>"Create", "expense"=>{"category"=>"cat", "account"=>"acc", "mode"=>"cash", "tran_date(1i)"=>"2010", "tran_date(2i)"=>"7", "description"=>"7/17 2238 ", "amount"=>"12.34", "tran_date(3i)"=>"18", "vendor"=>"65", "user_id"=>"rlm"}, "authenticity_token"=>"p0Vg6N2ZxXK/A9d2guWtlmqqsWYo5yj6Ey2+hgmPGCs="} Show session dump --- Response Headers: {"Content-Type"=>"", "Cache-Control"=>"no-cache"} On Jul 18, 4:17 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 17 Jul 2010, at 14:24, RichardOnRails <RichardDummyMailbox58...@USComputerGurus.com> wrote: > > > 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. > > It''s definitely in the form helpers guide - well worth reading (there''s also a section on collection_select and association type mismatch errors) > > > I also tried using the symbol :vendor_id as the first arg. That > > failed, too. > > That''s what you should be doing - how did it fail? > > Fred > > > 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > >> On Jul 16, 10:40 pm, RichardOnRails > > >> <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> 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-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 athttp://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.
Colin Law
2010-Jul-18 12:39 UTC
Re: Re: Added associations but don''t see generated methods
On 18 July 2010 13:22, RichardOnRails <RichardDummyMailbox58407-gP6xRNRnnqSxhq/XJNNIW0EOCMrvLtNR@public.gmane.org> wrote:> Hi Fred, > > I posted four files for easier viewing, I will also post details > below, though I find reading them unattractive. > > The code in question (I thought) was in app\views\expenses > \new.html.erb, specifically the lines: > <%# New version of vendor selection -%> > <% @vendors = Vendor.find( :all, :order=>"nickname ASC") -%> > <%= f.collection_select(:vendor_id, @vendors, :id, :nickname) %> > <%# NOTE: first argument, symbol :vendor, does not produce an > error here either -%> > <%# End of New version -%> > You may download the file in its entirety from > http://www.filefactory.com/file/b29d79e/n/new.html.erb > > However, the output from the crash indicates the failure was in line > 44 of the controller, > app\controllers\expenses_controller.rb > The code in the neighborhood around line 44 is: > # GET /expenses/1/edit > def edit > @expense = Expense.find(params[:id]) > end > > # POST /expenses > # POST /expenses.xml > def create > debugger # <== Line 44 > @expense = Expense.new(params[:expense]) > > respond_to do |format| > if @expense.save > flash[:notice] = ''Expense was successfully created.'' > format.html { redirect_to(@expense) } > format.xml { render :xml => @expense, :status > => :created, :location => @expense } > Apparently, the crash display-logic doesn''t think the "debugger" line > merits a line number. > You can download the controller in its entirety from: > http://www.filefactory.com/file/b3e9b86/n/expenses_controller.rb > > The dump from the crash is shown below. It strikes me as fairly ugly, > so I did screen captures which may be download from: > http://www.filefactory.com/file/b29d409/n/Z15-LowerPart.jpg > http://www.filefactory.com/file/b29d3h0/n/Z14-UpperPart.jpg > (My screen-capture utility doesn''t support scrolling, so I had to take > two images.) > > Incidentally, the crash dump includes a display of params[:expense], > which includes "vendor"=>"65". That''s what I''ve been trying to get, > i.e. the vendor field is now populated with the vendor::id of the > vendor I selected in the drop-down, rather than the vendor:nickname > that I used to get. Hooray!!Are you absolutely certain that the trace you show is as a result of the code you have posted? I would have expected the vendor id value (65) to be passed in vendor_id in params not vendor, as that is what you have put in your collection_select. Have a look at the html generated by the collection_select and see if that looks right. Colin> > I hope you can define a cause for my current crash. I can''t. > > Best wishes, > Richard > > ActiveRecord::AssociationTypeMismatch in ExpensesController#create > > Vendor(#37410590) expected, got String(#21132310) > > RAILS_ROOT: K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS > Application Trace | Framework Trace | Full Trace > > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/associations/association_proxy.rb: > 262:in `raise_on_type_mismatch'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/associations/ > belongs_to_association.rb:22:in `replace'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/associations.rb:1281:in `vendor='' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/base.rb:2746:in `send'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/base.rb:2746:in `attributes='' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/base.rb:2742:in `each'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/base.rb:2742:in `attributes='' > 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'' > > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/associations/association_proxy.rb: > 262:in `raise_on_type_mismatch'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/associations/ > belongs_to_association.rb:22:in `replace'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/associations.rb:1281:in `vendor='' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/base.rb:2746:in `send'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/base.rb:2746:in `attributes='' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/base.rb:2742:in `each'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/base.rb:2742:in `attributes='' > 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:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/base.rb:1331:in `send'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/base.rb:1331:in > `perform_action_without_filters'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/filters.rb:617:in > `call_filters'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/filters.rb:610:in > `perform_action_without_benchmark'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in > `perform_action_without_rescue'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in > `ms'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:10:in > `realtime'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in > `ms'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in > `perform_action_without_rescue'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/rescue.rb:160:in > `perform_action_without_flash'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/flash.rb:146:in > `perform_action'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/base.rb:532:in `send'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/base.rb:532:in > `process_without_filters'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/filters.rb:606:in `process'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/base.rb:391:in `process'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/base.rb:386:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/routing/route_set.rb:437:in > `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/dispatcher.rb:87:in `dispatch'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/dispatcher.rb:121:in `_call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/dispatcher.rb:130:in > `build_middleware_stack'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/query_cache.rb:29:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/query_cache.rb:29:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/connection_adapters/abstract/ > query_cache.rb:34:in `cache'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/query_cache.rb:9:in `cache'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/query_cache.rb:28:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/connection_adapters/abstract/ > connection_pool.rb:361:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/string_coercion.rb:25:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ > lib/rack/head.rb:9:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ > lib/rack/methodoverride.rb:24:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/params_parser.rb:15:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/session/cookie_store.rb:93:in > `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/failsafe.rb:26:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ > lib/rack/lock.rb:11:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ > lib/rack/lock.rb:11:in `synchronize'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ > lib/rack/lock.rb:11:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/dispatcher.rb:114:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/reloader.rb:34:in `run'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/dispatcher.rb:108:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/ > lib/rails/rack/static.rb:31:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ > lib/rack/urlmap.rb:46:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ > lib/rack/urlmap.rb:40:in `each'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ > lib/rack/urlmap.rb:40:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/ > lib/rails/rack/debugger.rb:19:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/ > lib/rails/rack/log_tailer.rb:17:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ > lib/rack/content_length.rb:13:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ > lib/rack/chunked.rb:15:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ > lib/rack/handler/mongrel.rb:64:in `process'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- > x86-mswin32-60/lib/mongrel.rb:159:in `process_client'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- > x86-mswin32-60/lib/mongrel.rb:158:in `each'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- > x86-mswin32-60/lib/mongrel.rb:158:in `process_client'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- > x86-mswin32-60/lib/mongrel.rb:285:in `run'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- > x86-mswin32-60/lib/mongrel.rb:285:in `initialize'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- > x86-mswin32-60/lib/mongrel.rb:285:in `new'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- > x86-mswin32-60/lib/mongrel.rb:285:in `run'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- > x86-mswin32-60/lib/mongrel.rb:268:in `initialize'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- > x86-mswin32-60/lib/mongrel.rb:268:in `new'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- > x86-mswin32-60/lib/mongrel.rb:268:in `run'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ > lib/rack/handler/mongrel.rb:34:in `run'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/ > lib/commands/server.rb:111 > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/site_ruby/1.8/rubygems/ > custom_require.rb:31:in `gem_original_require'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/site_ruby/1.8/rubygems/ > custom_require.rb:31:in `require'' > script/server:3 > > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/associations/association_proxy.rb: > 262:in `raise_on_type_mismatch'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/associations/ > belongs_to_association.rb:22:in `replace'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/associations.rb:1281:in `vendor='' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/base.rb:2746:in `send'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/base.rb:2746:in `attributes='' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/base.rb:2742:in `each'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/base.rb:2742:in `attributes='' > 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'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/base.rb:1331:in `send'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/base.rb:1331:in > `perform_action_without_filters'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/filters.rb:617:in > `call_filters'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/filters.rb:610:in > `perform_action_without_benchmark'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in > `perform_action_without_rescue'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in > `ms'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:10:in > `realtime'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in > `ms'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in > `perform_action_without_rescue'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/rescue.rb:160:in > `perform_action_without_flash'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/flash.rb:146:in > `perform_action'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/base.rb:532:in `send'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/base.rb:532:in > `process_without_filters'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/filters.rb:606:in `process'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/base.rb:391:in `process'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/base.rb:386:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/routing/route_set.rb:437:in > `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/dispatcher.rb:87:in `dispatch'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/dispatcher.rb:121:in `_call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/dispatcher.rb:130:in > `build_middleware_stack'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/query_cache.rb:29:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/query_cache.rb:29:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/connection_adapters/abstract/ > query_cache.rb:34:in `cache'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/query_cache.rb:9:in `cache'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/query_cache.rb:28:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/connection_adapters/abstract/ > connection_pool.rb:361:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/string_coercion.rb:25:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ > lib/rack/head.rb:9:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ > lib/rack/methodoverride.rb:24:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/params_parser.rb:15:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/session/cookie_store.rb:93:in > `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/failsafe.rb:26:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ > lib/rack/lock.rb:11:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ > lib/rack/lock.rb:11:in `synchronize'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ > lib/rack/lock.rb:11:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/dispatcher.rb:114:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/reloader.rb:34:in `run'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/dispatcher.rb:108:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/ > lib/rails/rack/static.rb:31:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ > lib/rack/urlmap.rb:46:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ > lib/rack/urlmap.rb:40:in `each'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ > lib/rack/urlmap.rb:40:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/ > lib/rails/rack/debugger.rb:19:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/ > lib/rails/rack/log_tailer.rb:17:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ > lib/rack/content_length.rb:13:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ > lib/rack/chunked.rb:15:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ > lib/rack/handler/mongrel.rb:64:in `process'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- > x86-mswin32-60/lib/mongrel.rb:159:in `process_client'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- > x86-mswin32-60/lib/mongrel.rb:158:in `each'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- > x86-mswin32-60/lib/mongrel.rb:158:in `process_client'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- > x86-mswin32-60/lib/mongrel.rb:285:in `run'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- > x86-mswin32-60/lib/mongrel.rb:285:in `initialize'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- > x86-mswin32-60/lib/mongrel.rb:285:in `new'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- > x86-mswin32-60/lib/mongrel.rb:285:in `run'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- > x86-mswin32-60/lib/mongrel.rb:268:in `initialize'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- > x86-mswin32-60/lib/mongrel.rb:268:in `new'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- > x86-mswin32-60/lib/mongrel.rb:268:in `run'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ > lib/rack/handler/mongrel.rb:34:in `run'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/ > lib/commands/server.rb:111 > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/site_ruby/1.8/rubygems/ > custom_require.rb:31:in `gem_original_require'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/site_ruby/1.8/rubygems/ > custom_require.rb:31:in `require'' > script/server:3 > > Request > > Parameters: > > {"commit"=>"Create", > "expense"=>{"category"=>"cat", > "account"=>"acc", > "mode"=>"cash", > "tran_date(1i)"=>"2010", > "tran_date(2i)"=>"7", > "description"=>"7/17 2238 ", > "amount"=>"12.34", > "tran_date(3i)"=>"18", > "vendor"=>"65", > "user_id"=>"rlm"}, > "authenticity_token"=>"p0Vg6N2ZxXK/A9d2guWtlmqqsWYo5yj6Ey2+hgmPGCs="} > > Show session dump > > --- > > Response > > Headers: > > {"Content-Type"=>"", > "Cache-Control"=>"no-cache"} > > > > On Jul 18, 4:17 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> On 17 Jul 2010, at 14:24, RichardOnRails <RichardDummyMailbox58...@USComputerGurus.com> wrote: >> >> > 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. >> >> It''s definitely in the form helpers guide - well worth reading (there''s also a section on collection_select and association type mismatch errors) >> >> > I also tried using the symbol :vendor_id as the first arg. That >> > failed, too. >> >> That''s what you should be doing - how did it fail? >> >> Fred >> >> > 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> > wrote: >> >> On Jul 16, 10:40 pm, RichardOnRails >> >> >> <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> 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-talk-/JYPxA39Uh5TLH3MbocFFw@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 athttp://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. > >-- 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.
RichardOnRails
2010-Jul-18 17:55 UTC
Re: Added associations but don''t see generated methods
Before I start, let me mention that I have posted a Microsoft Word document of the following response, along with two relevant files of the app here: http://www.filefactory.com/file/b29ea4f/n/Problem_writing_out_a_new_expense_record.doc http://www.filefactory.com/file/b29ea3c/n/new.html.erb http://www.filefactory.com/file/b29ea2c/n/expenses_controller.rb You may wish to download some or all for reference purposes of ease of reading.> Are you absolutely certain that the trace you show is as a result of the code you have posted?No. When I originally ran the app (and when I ran it just now), I had expense\new.html.erb set with: <%# New version of vendor selection -%> <% @vendors = Vendor.find( :all, :order=>"nickname ASC") -%> <%= f.collection_select(:vendor_id, @vendors, :id, :nickname) %> <%# NOTE: first argument, symbol :vendor, does not produce an error here either -%> <%# End of New version -%> Because of “vendor_id” in the collection_select, I get; NoMethodError in Expenses#new Showing app/views/expenses/new.html.erb where line #13 raised: undefined method `vendor_id'' for #<Expense:0x47034fc> 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: <%# NOTE: first argument, symbol :vendor, does not produce an error here either -%> 15: <%# End of New version -%> 16: But I had originally run it with (and just now changed it to): <%# New version of vendor selection -%> <% @vendors = Vendor.find( :all, :order=>"nickname ASC") -%> <%= f.collection_select(:vendor, @vendors, :id, :nickname) %> <%# NOTE: first argument, symbol :vendor, does not produce an error here -%> <%# End of New version -%> where I went back to :vendor (and removed “also” from my comment. I had changed to vendor_id because that’s what Frederick Cheung suggested, but I apparently changed it after I encountered the error in the Expense controller. Now with the change back to :vendor and clicking the “Reload current page” icon in Firefox, the Expense\new.html.erb pages is displayed without error. From there I click the down arrow in the item immediately below the Vendor tag and select the item with the vendor nickname “vendor 7/12/2010-1623” and populate the rest of the fields. Then when I click Create, I get the error display: ActiveRecord::AssociationTypeMismatch in ExpensesController#create Vendor(#37496880) expected, got String(#21132310) RAILS_ROOT: K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS Application Trace | Framework Trace | Full Trace K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/associations/association_proxy.rb: 262:in `raise_on_type_mismatch'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/associations/ belongs_to_association.rb:22:in `replace'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/associations.rb:1281:in `vendor='' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/base.rb:2746:in `send'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/base.rb:2746:in `attributes='' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/base.rb:2742:in `each'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/base.rb:2742:in `attributes='' 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:45:in `new'' K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS/app/controllers/ expenses_controller.rb:45:in `create'' Request Parameters: {"commit"=>"Create", "expense"=>{"category"=>"cat", "account"=>"acc", "mode"=>"cash", "tran_date(1i)"=>"2010", "tran_date(2i)"=>"7", "description"=>"7/12/2010-1623", "amount"=>"12.34", "tran_date(3i)"=>"18", "vendor"=>"65", "user_id"=>"rlm"}, "authenticity_token"=>"p0Vg6N2ZxXK/A9d2guWtlmqqsWYo5yj6Ey2+hgmPGCs="} Show session dump --- Response Headers: {"Content-Type"=>"", "Cache-Control"=>"no-cache"} For some reason, this above dump does not display line 45 nor its context. But the relevant portion of app\controllers \expenses_controller.rb is shown here: # POST /expenses # POST /expenses.xml def create debugger @expense = Expense.new(params[:expense]) # <== Line 45 ***************** respond_to do |format| if @expense.save flash[:notice] = ''Expense was successfully created.'' format.html { redirect_to(@expense) } format.xml { render :xml => @expense, :status => :created, :location => @expense } else format.html { render :action => "new" } format.xml { render :xml => @expense.errors, :status => :unprocessable_entity } end end end I note that the params["expense"]["vendor"]=>"65", which I view as almost perfect, i.e. it’s a vendor ID as opposed to a vendor nickname. But is it the ID matching my selection? It is indeed, as witnessed by the fact: mysql> select * from vendors; +----+-----------------------+---------------------------------- +---------------------+---------------------+ | id | nickname | qbname | created_at | updated_at | +----+-----------------------+---------------------------------- +---------------------+---------------------+ | 62 | vendor 5/15/2010 | Test new field names | 2010-05-15 16:30:11 | 2010-05-15 16:30:11 | | 63 | vendor 5/21/2010 | Testing pre-plugin version | 2010-05-21 19:38:36 | 2010-05-21 19:38:36 | | 64 | Z01-2010.06.26 | Z01-Test | 2010-06-26 14:28:11 | 2010-06-26 14:28:11 | | 65 | vendor 7/12/2010-1623 | Just a test of "belongs_to", etc | 2010-07-12 20:25:05 | 2010-07-12 20:35:11 | +----+-----------------------+---------------------------------- +---------------------+---------------------+ I hope you can see what''s wrong here. Maybe I should just rebuild the Expense portion in its entirety, now that I''m so close to getting the ID of a selected vendor to appear ready to be saved in new expense records. 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 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.
Frederick Cheung
2010-Jul-18 19:14 UTC
Re: Re: Added associations but don''t see generated methods
On 18 Jul 2010, at 18:55, RichardOnRails <RichardDummyMailbox58407@USComputerGurus.com> wrote:> > > Then when I click Create, I get the error display: > ActiveRecord::AssociationTypeMismatch in ExpensesController#create > Vendor(#37496880) expected, got String(#21132310)This is precisely the error you''ll get if you put :vendor (the name of the association) rather than :vendor_id (the name of the attribute). There''s a section explaining why this happens in the form helpers guide (at guides.rubyonrails.org )> RAILS_ROOT: K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS > Application Trace | Framework Trace | Full Trace > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/associations/association_proxy.rb: > 262:in `raise_on_type_mismatch'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/associations/ > belongs_to_association.rb:22:in `replace'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/associations.rb:1281:in `vendor='' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/base.rb:2746:in `send'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/base.rb:2746:in `attributes='' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/base.rb:2742:in `each'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/base.rb:2742:in `attributes='' > 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:45:in `new'' > K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS/app/controllers/ > expenses_controller.rb:45:in `create'' > Request > Parameters: > {"commit"=>"Create", > "expense"=>{"category"=>"cat", > "account"=>"acc", > "mode"=>"cash", > "tran_date(1i)"=>"2010", > "tran_date(2i)"=>"7", > "description"=>"7/12/2010-1623", > "amount"=>"12.34", > "tran_date(3i)"=>"18", > "vendor"=>"65", > "user_id"=>"rlm"}, > "authenticity_token"=>"p0Vg6N2ZxXK/A9d2guWtlmqqsWYo5yj6Ey2+hgmPGCs="} > Show session dump > --- > Response > Headers: > {"Content-Type"=>"", > "Cache-Control"=>"no-cache"} > > For some reason, this above dump does not display line 45 nor its > context. But the relevant portion of app\controllers > \expenses_controller.rb is shown here: > # POST /expenses > # POST /expenses.xml > def create > debugger > @expense = Expense.new(params[:expense]) # <== Line 45 > ***************** > > respond_to do |format| > if @expense.save > flash[:notice] = ''Expense was successfully created.'' > format.html { redirect_to(@expense) } > format.xml { render :xml => @expense, :status > => :created, :location => @expense } > else > format.html { render :action => "new" } > format.xml { render :xml => @expense.errors, :status > => :unprocessable_entity } > end > end > end > > I note that the params["expense"]["vendor"]=>"65", which I view as > almost perfect, i.e. it’s a vendor ID as opposed to a vendor > nickname. But is it the ID matching my selection? > > It is indeed, as witnessed by the fact: > mysql> select * from vendors; > +----+-----------------------+---------------------------------- > +---------------------+---------------------+ > | id | nickname | qbname | > created_at | updated_at | > +----+-----------------------+---------------------------------- > +---------------------+---------------------+ > | 62 | vendor 5/15/2010 | Test new field names | > 2010-05-15 16:30:11 | 2010-05-15 16:30:11 | > | 63 | vendor 5/21/2010 | Testing pre-plugin version | > 2010-05-21 19:38:36 | 2010-05-21 19:38:36 | > | 64 | Z01-2010.06.26 | Z01-Test | > 2010-06-26 14:28:11 | 2010-06-26 14:28:11 | > | 65 | vendor 7/12/2010-1623 | Just a test of "belongs_to", etc | > 2010-07-12 20:25:05 | 2010-07-12 20:35:11 | > +----+-----------------------+---------------------------------- > +---------------------+---------------------+ > > I hope you can see what''s wrong here. Maybe I should just rebuild the > Expense portion in its entirety, now that I''m so close to getting the > ID of a selected vendor to appear ready to be saved in new expense > records. > > 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 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.
Colin Law
2010-Jul-18 20:48 UTC
Re: Re: Added associations but don''t see generated methods
On 18 July 2010 18:55, RichardOnRails <RichardDummyMailbox58407-gP6xRNRnnqSxhq/XJNNIW0EOCMrvLtNR@public.gmane.org> wrote:> Before I start, let me mention that I have posted a Microsoft Word > document of the following response, along with two relevant files of > the app here: > http://www.filefactory.com/file/b29ea4f/n/Problem_writing_out_a_new_expense_record.doc > http://www.filefactory.com/file/b29ea3c/n/new.html.erb > http://www.filefactory.com/file/b29ea2c/n/expenses_controller.rb > You may wish to download some or all for reference purposes of ease of > reading. > >> Are you absolutely certain that the trace you show is as a result of the code you have posted? > No. When I originally ran the app (and when I ran it just now), I > had expense\new.html.erb set with: > <%# New version of vendor selection -%> > <% @vendors = Vendor.find( :all, :order=>"nickname ASC") -%> > <%= f.collection_select(:vendor_id, @vendors, :id, :nickname) %> > <%# NOTE: first argument, symbol :vendor, does not produce an > error here either -%> > <%# End of New version -%> > > Because of “vendor_id” in the collection_select, I get; > NoMethodError in Expenses#new > Showing app/views/expenses/new.html.erb where line #13 raised: > undefined method `vendor_id'' for #<Expense:0x47034fc>I presume you *have* got a vendor_id column in the expenses table? 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-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.
RichardOnRails
2010-Jul-18 21:22 UTC
Re: Added associations but don''t see generated methods
Hey Fred and Colin,> I presume you *have* got a vendor_id column in the expenses table?No, I don''t. I thought that''s the kind of thing was generated dynamically. But now that you ask, I see that dynamic generation of methods would extend to the addition of columns to tables On second thought, vendor_id should be in the join_table, not in the expense_table. And that''s true: .mysql> show columns in expenses_vendor; +-------------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+----------+------+-----+---------+-------+ | expenses_id | int(11) | YES | | NULL | | | vendor_id | int(11) | YES | | NULL | | | created_at | datetime | YES | | NULL | | +-------------+----------+------+-----+---------+-------+ 3 rows in set (0.31 sec) So why does: <%# New version of vendor selection -%> <% @vendors = Vendor.find( :all, :order=>"nickname ASC") -%> <%= f.collection_select(:vendor, @vendors, :id, :nickname) %> <%# NOTE: first argument, symbol :vendor, does not produce an error here -%> <%# End of New version -%> fail when I use vendor_id as the first argument of collection_select, i.e. NoMethodError in Expenses#new Showing app/views/expenses/new.html.erb where line #13 raised: undefined method `vendor_id'' for #<Expense:0x47fa518> 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: <%# NOTE: first argument, symbol :vendor, does not produce an error here -%> 15: <%# End of New version -%> 16: RAILS_ROOT: K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS Application Trace | Framework Trace | Full Trace K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/attribute_methods.rb:260:in `method_missing'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:838:in `send'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:838:in `value'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:829:in `value'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/helpers/form_options_helper.rb:539:in `to_collection_select_tag'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/helpers/form_options_helper.rb:162:in `collection_select'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/helpers/form_options_helper.rb:588:in `collection_select'' K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS/app/views/expenses/ new.html.erb:13:in `_run_erb_app47views47expenses47new46html46erb'' K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS/app/views/expenses/ new.html.erb:5:in `_run_erb_app47views47expenses47new46html46erb'' K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS/app/controllers/ expenses_controller.rb:30:in `new'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/attribute_methods.rb:260:in `method_missing'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:838:in `send'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:838:in `value'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:829:in `value'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/helpers/form_options_helper.rb:539:in `to_collection_select_tag'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/helpers/form_options_helper.rb:162:in `collection_select'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/helpers/form_options_helper.rb:588:in `collection_select'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:499:in `fields_for'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:282:in `form_for'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/renderable.rb:34:in `send'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/renderable.rb:34:in `render'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/base.rb:306:in `with_template'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/renderable.rb:30:in `render'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/template.rb:205:in `render_template'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/base.rb:265:in `render'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/base.rb:348:in `_render_with_layout'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/base.rb:262:in `render'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:1250:in `render_for_file'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:951:in `render_without_benchmark'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/benchmarking.rb:51:in `render'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:10:in `realtime'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/benchmarking.rb:51:in `render'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/mime_responds.rb:135:in `send'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/mime_responds.rb:135:in `custom'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/mime_responds.rb:179:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/mime_responds.rb:179:in `respond'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/mime_responds.rb:173:in `each'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/mime_responds.rb:173:in `respond'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/mime_responds.rb:107:in `respond_to'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:1331:in `send'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:1331:in `perform_action_without_filters'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/filters.rb:617:in `call_filters'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:10:in `realtime'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/flash.rb:146:in `perform_action'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:532:in `send'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:532:in `process_without_filters'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/filters.rb:606:in `process'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:391:in `process'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:386:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/routing/route_set.rb:437:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/dispatcher.rb:87:in `dispatch'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/dispatcher.rb:121:in `_call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/dispatcher.rb:130:in `build_middleware_stack'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/query_cache.rb:29:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/query_cache.rb:29:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/connection_adapters/abstract/ query_cache.rb:34:in `cache'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/query_cache.rb:9:in `cache'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/query_cache.rb:28:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/connection_adapters/abstract/ connection_pool.rb:361:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/string_coercion.rb:25:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/head.rb:9:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/methodoverride.rb:24:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/params_parser.rb:15:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/session/cookie_store.rb:93:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/failsafe.rb:26:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/lock.rb:11:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/lock.rb:11:in `synchronize'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/lock.rb:11:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/dispatcher.rb:114:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/reloader.rb:34:in `run'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/dispatcher.rb:108:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/ lib/rails/rack/static.rb:31:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/urlmap.rb:46:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/urlmap.rb:40:in `each'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/urlmap.rb:40:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/ lib/rails/rack/log_tailer.rb:17:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/content_length.rb:13:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/chunked.rb:15:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/handler/mongrel.rb:64:in `process'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:159:in `process_client'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:158:in `each'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:158:in `process_client'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:285:in `run'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:285:in `initialize'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:285:in `new'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:285:in `run'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:268:in `initialize'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:268:in `new'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:268:in `run'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/handler/mongrel.rb:34:in `run'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/ lib/commands/server.rb:111 K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:31:in `gem_original_require'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:31:in `require'' script/server:3 K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/attribute_methods.rb:260:in `method_missing'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:838:in `send'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:838:in `value'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:829:in `value'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/helpers/form_options_helper.rb:539:in `to_collection_select_tag'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/helpers/form_options_helper.rb:162:in `collection_select'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/helpers/form_options_helper.rb:588:in `collection_select'' K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS/app/views/expenses/ new.html.erb:13:in `_run_erb_app47views47expenses47new46html46erb'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:499:in `fields_for'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:282:in `form_for'' K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS/app/views/expenses/ new.html.erb:5:in `_run_erb_app47views47expenses47new46html46erb'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/renderable.rb:34:in `send'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/renderable.rb:34:in `render'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/base.rb:306:in `with_template'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/renderable.rb:30:in `render'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/template.rb:205:in `render_template'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/base.rb:265:in `render'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/base.rb:348:in `_render_with_layout'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_view/base.rb:262:in `render'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:1250:in `render_for_file'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:951:in `render_without_benchmark'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/benchmarking.rb:51:in `render'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:10:in `realtime'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/benchmarking.rb:51:in `render'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/mime_responds.rb:135:in `send'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/mime_responds.rb:135:in `custom'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/mime_responds.rb:179:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/mime_responds.rb:179:in `respond'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/mime_responds.rb:173:in `each'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/mime_responds.rb:173:in `respond'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/mime_responds.rb:107:in `respond_to'' K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS/app/controllers/ expenses_controller.rb:30:in `new'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:1331:in `send'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:1331:in `perform_action_without_filters'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/filters.rb:617:in `call_filters'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:10:in `realtime'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/flash.rb:146:in `perform_action'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:532:in `send'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:532:in `process_without_filters'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/filters.rb:606:in `process'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:391:in `process'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/base.rb:386:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/routing/route_set.rb:437:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/dispatcher.rb:87:in `dispatch'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/dispatcher.rb:121:in `_call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/dispatcher.rb:130:in `build_middleware_stack'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/query_cache.rb:29:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/query_cache.rb:29:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/connection_adapters/abstract/ query_cache.rb:34:in `cache'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/query_cache.rb:9:in `cache'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/query_cache.rb:28:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.3.5/lib/active_record/connection_adapters/abstract/ connection_pool.rb:361:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/string_coercion.rb:25:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/head.rb:9:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/methodoverride.rb:24:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/params_parser.rb:15:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/session/cookie_store.rb:93:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/failsafe.rb:26:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/lock.rb:11:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/lock.rb:11:in `synchronize'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/lock.rb:11:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/dispatcher.rb:114:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/reloader.rb:34:in `run'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ actionpack-2.3.5/lib/action_controller/dispatcher.rb:108:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/ lib/rails/rack/static.rb:31:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/urlmap.rb:46:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/urlmap.rb:40:in `each'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/urlmap.rb:40:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/ lib/rails/rack/log_tailer.rb:17:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/content_length.rb:13:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/chunked.rb:15:in `call'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/handler/mongrel.rb:64:in `process'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:159:in `process_client'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:158:in `each'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:158:in `process_client'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:285:in `run'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:285:in `initialize'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:285:in `new'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:285:in `run'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:268:in `initialize'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:268:in `new'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5- x86-mswin32-60/lib/mongrel.rb:268:in `run'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/ lib/rack/handler/mongrel.rb:34:in `run'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/ lib/commands/server.rb:111 K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:31:in `gem_original_require'' K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:31:in `require'' script/server:3 Request Parameters: None Show session dump --- Response Headers: {"Content-Type"=>"text/html", "Cache-Control"=>"no-cache"} Could it be I need to add some path of sorts in front of vendor_id, e.g. expenses_vendor/vendor_id. Just grasping at straws here. Is there any solution to my dilemma? Best wishes to you both, Richad -- 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.
RichardOnRails
2010-Jul-18 21:46 UTC
Re: Added associations but don''t see generated methods
OK Guys, I think I understand the problem now. We''ve got to populate the join- table with the ID of the new Expanse record and the ID of the selected Vendor record. Heretofore, I thought using vendor instead of Fred''s vendor_id was cool because: 1. It didn''t crash the new Expense record 2. It populated the Expense vendor field with the ID of the selected vendor. Only now do I see that our goal is to populate the join-table. My idea of qualifying vendor_id as expenses_vendor/:vendor didn''t fly. But you guys sound like you''ve got enough experience in Rails to see through this problem. I keeping my fingers crossed.> Best wishes to you both, > Richad-- 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.
RichardOnRails
2010-Jul-18 22:13 UTC
Re: Added associations but don''t see generated methods
Hey Guys, How about this idea. 1. We revert to vendor as the first arg to collection_select. 2. That populates params["expense"]["vendor"] with the selected vendor''s ID 3. We create an observer on the Create button 4. In the observer, we create a new join record and populate it with: a. The new Expense record''s ID b. The selected vendor''s ID c. Save the the join record. Ideally, that''s what collection_select would do for us if we could invoke it in just the right way. Any votes in favor of this idea? Best wishes, Richard On Jul 18, 5:46 pm, RichardOnRails <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> wrote:> OK Guys, > > I think I understand the problem now. We''ve got to populate the join- > table with the ID of the new Expanse record and the ID of the selected > Vendor record. > > Heretofore, I thought using vendor instead of Fred''s vendor_id was > cool because: > 1. It didn''t crash the new Expense record > 2. It populated the Expense vendor field with the ID of the selected > vendor. > > Only now do I see that our goal is to populate the join-table. My > idea of qualifying vendor_id as expenses_vendor/:vendor didn''t fly. > But you guys sound like you''ve got enough experience in Rails to see > through this problem. I keeping my fingers crossed. > > > Best wishes to you both, > > Richad-- 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.
RichardOnRails
2010-Jul-18 23:56 UTC
Re: Added associations but don''t see generated methods
In stead of the observer idea, how about switching to an option containing the link-record creation/population with the caveat that the join-table be checked for the existence of a join-record for the current expense-record ID, offering to overwrite the existing link or canceling the new-link request. That sounds pretty simple. Any fans of this idea? Best, Richard On Jul 18, 6:13 pm, RichardOnRails <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> wrote:> Hey Guys, > > How about this idea. > 1. We revert to vendor as the first arg to collection_select. > 2. That populates params["expense"]["vendor"] with the selected > vendor''s ID > 3. We create an observer on the Create button > 4. In the observer, we create a new join record and populate it > with: > a. The new Expense record''s ID > b. The selected vendor''s ID > c. Save the the join record. > > Ideally, that''s what collection_select would do for us if we could > invoke it in just the right way. > > Any votes in favor of this idea? > > Best wishes, > Richard > > On Jul 18, 5:46 pm, RichardOnRails > > <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> wrote: > > OK Guys, > > > I think I understand the problem now. We''ve got to populate the join- > > table with the ID of the new Expanse record and the ID of the selected > > Vendor record. > > > Heretofore, I thought using vendor instead of Fred''s vendor_id was > > cool because: > > 1. It didn''t crash the new Expense record > > 2. It populated the Expense vendor field with the ID of the selected > > vendor. > > > Only now do I see that our goal is to populate the join-table. My > > idea of qualifying vendor_id as expenses_vendor/:vendor didn''t fly. > > But you guys sound like you''ve got enough experience in Rails to see > > through this problem. I keeping my fingers crossed. > > > > Best wishes to you both, > > > Richad-- 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.
Frederick Cheung
2010-Jul-19 06:58 UTC
Re: Added associations but don''t see generated methods
On Jul 18, 10:22 pm, RichardOnRails <RichardDummyMailbox58...-FtJgd9dCuO3JTKoYRCtP1UEOCMrvLtNR@public.gmane.org> wrote:> Hey Fred and Colin, > > > I presume you *have* got a vendor_id column in the expenses table? > > No, I don''t. I thought that''s the kind of thing was generated > dynamically. But now that you ask, I see that dynamic generation of > methods would extend to the addition of columns to tablesThey aren;t> > On second thought, vendor_id should be in the join_table, not in the > expense_table. And that''s true:Wrong. You''ve got a belongs_to/has_many so there is no join table.> So why does: > <%# New version of vendor selection -%> > <% @vendors = Vendor.find( :all, :order=>"nickname ASC") -%> > <%= f.collection_select(:vendor, @vendors, :id, :nickname) %> > <%# NOTE: first argument, symbol :vendor, does not produce an > error here -%> > <%# End of New version -%> > fail when I use vendor_id as the first argument of collection_select, > i.e. > > NoMethodError in Expenses#new > > Showing app/views/expenses/new.html.erb where line #13 raised: > > undefined method `vendor_id'' for #<Expense:0x47fa518> >Because Expense doesn''t have a vendor_id method since you haven''t added that column to it. I''d recommend having another read of http://guides.rubyonrails.org/association_basics.html Fred> 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: <%# NOTE: first argument, symbol :vendor, does not produce an > error here -%> > 15: <%# End of New version -%> > 16: > > RAILS_ROOT: K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS > Application Trace | Framework Trace | Full Trace > > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/attribute_methods.rb:260:in > `method_missing'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:838:in `send'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:838:in `value'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:829:in `value'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_view/helpers/form_options_helper.rb:539:in > `to_collection_select_tag'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_view/helpers/form_options_helper.rb:162:in > `collection_select'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_view/helpers/form_options_helper.rb:588:in > `collection_select'' > K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS/app/views/expenses/ > new.html.erb:13:in `_run_erb_app47views47expenses47new46html46erb'' > K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS/app/views/expenses/ > new.html.erb:5:in `_run_erb_app47views47expenses47new46html46erb'' > K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS/app/controllers/ > expenses_controller.rb:30:in `new'' > > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activerecord-2.3.5/lib/active_record/attribute_methods.rb:260:in > `method_missing'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:838:in `send'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:838:in `value'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:829:in `value'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_view/helpers/form_options_helper.rb:539:in > `to_collection_select_tag'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_view/helpers/form_options_helper.rb:162:in > `collection_select'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_view/helpers/form_options_helper.rb:588:in > `collection_select'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:499:in > `fields_for'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:282:in > `form_for'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_view/renderable.rb:34:in `send'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_view/renderable.rb:34:in `render'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_view/base.rb:306:in `with_template'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_view/renderable.rb:30:in `render'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_view/template.rb:205:in `render_template'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_view/base.rb:265:in `render'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_view/base.rb:348:in `_render_with_layout'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_view/base.rb:262:in `render'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/base.rb:1250:in > `render_for_file'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/base.rb:951:in > `render_without_benchmark'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/benchmarking.rb:51:in `render'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in > `ms'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:10:in > `realtime'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in > `ms'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/benchmarking.rb:51:in `render'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/mime_responds.rb:135:in `send'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/mime_responds.rb:135:in > `custom'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/mime_responds.rb:179:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/mime_responds.rb:179:in > `respond'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/mime_responds.rb:173:in `each'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/mime_responds.rb:173:in > `respond'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/mime_responds.rb:107:in > `respond_to'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/base.rb:1331:in `send'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/base.rb:1331:in > `perform_action_without_filters'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/filters.rb:617:in > `call_filters'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/filters.rb:610:in > `perform_action_without_benchmark'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in > `perform_action_without_rescue'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in > `ms'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:10:in > `realtime'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in > `ms'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in > `perform_action_without_rescue'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/rescue.rb:160:in > `perform_action_without_flash'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/flash.rb:146:in > `perform_action'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/base.rb:532:in `send'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/base.rb:532:in > `process_without_filters'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/filters.rb:606:in `process'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/base.rb:391:in `process'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/base.rb:386:in `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/routing/route_set.rb:437:in > `call'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/dispatcher.rb:87:in `dispatch'' > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ > actionpack-2.3.5/lib/action_controller/dispatcher.rb:121:in `_call'' ... > > read more »-- 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.
Colin Law
2010-Jul-19 07:03 UTC
Re: Re: Added associations but don''t see generated methods
On 19 July 2010 00:56, RichardOnRails <RichardDummyMailbox58407-gP6xRNRnnqSxhq/XJNNIW0EOCMrvLtNR@public.gmane.org> wrote:> In stead of the observer idea, how about switching to an option > containing the link-record creation/population with the caveat that > the join-table be checked for the existence of a join-record for the > current expense-record ID, offering to overwrite the existing link or > canceling the new-link request. > > That sounds pretty simple. Any fans of this idea?I am sorry Richard I have completely lost track of what you are trying to do, and have no idea what the relationships between your models is. Have you worked through Rails Guide on Active Record Relationships? I mean worked through it and understood all the concepts there, and experimented with the code there to see how it all works. If not then I suggest you do it. Then do the same for the other guides there. When you have done that then hopefully you will have a better idea of how to organise your relationships and what fields you need to put in the tables. Then I suggest you work right through some tutorials, I like the one at http://railstutorial.org/. The one in Agile Development with Rails is also excellent. When you have done the above then you should have a much better idea of the basics or Rails. If you still have problems then come back again, with a new thread, and try again. 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-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.
RichardOnRails
2010-Jul-19 13:00 UTC
Re: Added associations but don''t see generated methods
OK Fred and Colin, Problem solved: Throw away the join table; add a vendor_id column to the expense table; use vendor_id in the collection_select method. This has been a thorn in my side for a long time. I''m so relieved to learn the way out of my dilemma. Best wishes, Richard On Jul 19, 3:03 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 19 July 2010 00:56, RichardOnRails > > <RichardDummyMailbox58...-gP6xRNRnnqSxhq/XJNNIW0EOCMrvLtNR@public.gmane.org> wrote: > > In stead of the observer idea, how about switching to an option > > containing the link-record creation/population with the caveat that > > the join-table be checked for the existence of a join-record for the > > current expense-record ID, offering to overwrite the existing link or > > canceling the new-link request. > > > That sounds pretty simple. Any fans of this idea? > > I am sorry Richard I have completely lost track of what you are trying > to do, and have no idea what the relationships between your models is. > Have you worked through Rails Guide on Active Record Relationships? > I mean worked through it and understood all the concepts there, and > experimented with the code there to see how it all works. If not then > I suggest you do it. Then do the same for the other guides there. > > When you have done that then hopefully you will have a better idea of > how to organise your relationships and what fields you need to put in > the tables. > > Then I suggest you work right through some tutorials, I like the one > athttp://railstutorial.org/. The one in Agile Development with Rails > is also excellent. > > When you have done the above then you should have a much better idea > of the basics or Rails. If you still have problems then come back > again, with a new thread, and try again. > > 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-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.