I''ve asked this in various ways but I can''t seem to get much traction - my guess is because not many people are doing this. I am working in a controller/views called placements. Placements belongs_to :client I have a clients model/table - clients has_many :placements in placements/find...this works fine... <%= text_field_with_auto_complete :placement, :clwholename, {} %> if I put the same code into placements/new or placements/edit, I get a No method ''clwholename'' error The method is defined at the top of placements_controller.rb ... def auto_complete_for_placement_clwholename auto_complete_responder_for_clients params[:placement][:clwholename] end I have taken the entire code from the view file placements/find.rhtml and pasted it into placements/new and still get the same error. The only difference of any significance I can figure out is that the methods are slightly different... def find @placements = Placement.find(:all) whereas def new @placement = Placement.new and def edit @placement = Placement.find(params[:id]) but that wouldn''t seem to be enough to break it would it? I have spent various amounts of time the past few weeks playing with this but it is rapidly coming to the point where it is holding me back. Why would the auto_complete_for ''column from other model'' work with a find method but not edit/new methods? Craig
> I''ve asked this in various ways but I can''t seem to get much > traction - > my guess is because not many people are doing this. > > I am working in a controller/views called placements. Placements > belongs_to :client > I have a clients model/table - clients has_many :placements > > in placements/find...this works fine... > <%= text_field_with_auto_complete :placement, :clwholename, {} %> > > if I put the same code into placements/new or placements/edit, I get a > No method ''clwholename'' errorI have not used text_field_with_auto_complete before, but I see it is a wrapper for text_field. I would guess it means the same in both. The error means the text_field is looking for an initial value and it does this by calling @object.method (in your case: @placement.clwholename). If the instance variable @placement is not set to an object that has a method clwholename then you get this error.> > The method is defined at the top of placements_controller.rb ... > def auto_complete_for_placement_clwholename > auto_complete_responder_for_clients params[:placement] > [:clwholename] > end > > I have taken the entire code from the view file placements/find.rhtml > and pasted it into placements/new and still get the same error. > > The only difference of any significance I can figure out is that the > methods are slightly different... > > def find > @placements = Placement.find(:all) > > whereas > def new > @placement = Placement.new > > and def edit > @placement = Placement.find(params[:id]) > > but that wouldn''t seem to be enough to break it would it? > > I have spent various amounts of time the past few weeks playing with > this but it is rapidly coming to the point where it is holding me > back. > Why would the auto_complete_for ''column from other model'' work with a > find method but not edit/new methods? > > Craig > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-John -- John Smilanick Computing Staff - Webmaster Kavli Institute for Theoretical Physics University of California, Santa Barbara jsmilani@kitp.ucsb.edu (805) 893-6307
On Tue, 2006-03-14 at 11:26 -0800, John Smilanick wrote:> > I''ve asked this in various ways but I can''t seem to get much > > traction - > > my guess is because not many people are doing this. > > > > I am working in a controller/views called placements. Placements > > belongs_to :client > > I have a clients model/table - clients has_many :placements > > > > in placements/find...this works fine... > > <%= text_field_with_auto_complete :placement, :clwholename, {} %> > > > > if I put the same code into placements/new or placements/edit, I get a > > No method ''clwholename'' error > I have not used text_field_with_auto_complete before, but I see it is > a wrapper for text_field. I would guess it means the same in both. > The error means the text_field is looking for an initial value and it > does this by calling @object.method (in your case: > @placement.clwholename). If the instance variable @placement is not > set to an object that has a method clwholename then you get this error.---- hmmm...perhaps I''ve just been chasing the wrong dog all this time. I will try to set it with an empty value within the method and see if it makes happy method. thanks Craig