damien
2008-Jan-07 08:26 UTC
text_field_with_auto_complete does not actually auto complete
I''m using Rails 2.0 and installed the plug-in for auto-complete. The page shows up fine... the problem is that the text_field_with_auto_complete in the view doesn''t actually auto- complete. Since I hand populated the database I know what to search for, but it just won''t show me any suggestions. If someone might be able to point out what I''m doing wrong I''d greatly appreciate it. Below are some code snippets from my very basic project. #VIEW _search.html.erb <H3>Search for Your Error Message Below</H3> <%= text_field_with_auto_complete :solution, :error_name %> #VIEW index.html.erb <H1>Welcome to the Solutions Lookup Database</H1> <%= render :partial => ''search'' %> #CONTROLLER solutions_controller.rb class SolutionsController < ApplicationController auto_complete_for :solution, :error_name def index end def search :partial end end #MIGRATION 002_testpopulationsolutions.rb class Testpopulatesolutions < ActiveRecord::Migration def self.up Solution.create :error_name => "404", :description => "Website could not be found.", :solution_steps => "Contact admin." Solution.create :error_name => "ip conflict", :description => "Your computer has the same network address as another.", :solution_steps => "Contact admin." Solution.create :error_name => "computer restarts", :description => "Computer is most likely overheating.", :solution_steps => "Blow out vents with compressed duster." end def self.down drop_table :solutions create_table :solutions do |t| t.column :error_name, :string t.column :description, :text t.column :solution_steps, :text end end end --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Nicolás Sanguinetti
2008-Jan-07 14:06 UTC
Re: text_field_with_auto_complete does not actually auto complete
Do you have <%= javascript_include_tag :defaults %> in your layout inside the <head> tag? Best, -Nicolas On Jan 7, 2008 6:26 AM, damien <Mike.Pyronet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I''m using Rails 2.0 and installed the plug-in for auto-complete. > > The page shows up fine... the problem is that the > text_field_with_auto_complete in the view doesn''t actually auto- > complete. Since I hand populated the database I know what to search > for, but it just won''t show me any suggestions. > > If someone might be able to point out what I''m doing wrong I''d greatly > appreciate it. Below are some code snippets from my very basic > project. > > #VIEW _search.html.erb > <H3>Search for Your Error Message Below</H3> > > <%= text_field_with_auto_complete :solution, :error_name %> > > #VIEW index.html.erb > <H1>Welcome to the Solutions Lookup Database</H1> > > <%= render :partial => ''search'' %> > > #CONTROLLER solutions_controller.rb > class SolutionsController < ApplicationController > auto_complete_for :solution, :error_name > def index > > end > def search > :partial > end > end > > #MIGRATION 002_testpopulationsolutions.rb > class Testpopulatesolutions < ActiveRecord::Migration > def self.up > Solution.create :error_name => "404", :description => "Website could > not be found.", :solution_steps => "Contact admin." > Solution.create :error_name => "ip conflict", :description => "Your > computer has the same network address as another.", :solution_steps => > "Contact admin." > Solution.create :error_name => "computer restarts", :description => > "Computer is most likely overheating.", :solution_steps => "Blow out > vents with compressed duster." > end > > def self.down > drop_table :solutions > create_table :solutions do |t| > t.column :error_name, :string > t.column :description, :text > t.column :solution_steps, :text > end > end > end > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
damien
2008-Jan-07 19:57 UTC
Re: text_field_with_auto_complete does not actually auto complete
No, I didn''t have that tag. It turns out though that using the <%javascript_include_tag :defaults %> works outside the header (just in case you wanted to know). I also found out that to defend against sessions fixation attacks, rails uses a setting called allow_forgery_detection which was causing problems with the POST data for the text_field_with_auto_complete, giving me a "ActionController::InvalidAuthenticityToken" error message which I was able to find using the Firebug plugin for Firefox. Since my project doesn''t require any authentication (it''s just a giant free database) I just added the line self.allow_forgery_protection = false into my application.rb file. Everything works now as it should. Thanks for the help! On Jan 7, 6:06 am, "Nicolás Sanguinetti" <godf...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Do you have <%= javascript_include_tag :defaults %> in your layout > inside the <head> tag? > > Best, > -Nicolas > > On Jan 7, 2008 6:26 AM, damien <Mike.Pyro...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I''m using Rails 2.0 and installed the plug-in for auto-complete. > > > The page shows up fine... the problem is that the > > text_field_with_auto_complete in the view doesn''t actually auto- > > complete. Since I hand populated the database I know what to search > > for, but it just won''t show me any suggestions. > > > If someone might be able to point out what I''m doing wrong I''d greatly > > appreciate it. Below are some code snippets from my very basic > > project. > > > #VIEW _search.html.erb > > <H3>Search for Your Error Message Below</H3> > > > <%= text_field_with_auto_complete :solution, :error_name %> > > > #VIEW index.html.erb > > <H1>Welcome to the Solutions Lookup Database</H1> > > > <%= render :partial => ''search'' %> > > > #CONTROLLER solutions_controller.rb > > class SolutionsController < ApplicationController > > auto_complete_for :solution, :error_name > > def index > > > end > > def search > > :partial > > end > > end > > > #MIGRATION 002_testpopulationsolutions.rb > > class Testpopulatesolutions < ActiveRecord::Migration > > def self.up > > Solution.create :error_name => "404", :description => "Website could > > not be found.", :solution_steps => "Contact admin." > > Solution.create :error_name => "ip conflict", :description => "Your > > computer has the same network address as another.", :solution_steps => > > "Contact admin." > > Solution.create :error_name => "computer restarts", :description => > > "Computer is most likely overheating.", :solution_steps => "Blow out > > vents with compressed duster." > > end > > > def self.down > > drop_table :solutions > > create_table :solutions do |t| > > t.column :error_name, :string > > t.column :description, :text > > t.column :solution_steps, :text > > end > > end > > end--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Nicolás Sanguinetti
2008-Jan-07 20:23 UTC
Re: text_field_with_auto_complete does not actually auto complete
On Jan 7, 2008 5:57 PM, damien <Mike.Pyronet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > No, I didn''t have that tag. It turns out though that using the <%> javascript_include_tag :defaults %> works outside the header (just in > case you wanted to know).It will work anywhere, as long as it''s before the text_field_with_auto_complete tag. Best, -Nicolas> I also found out that to defend against sessions fixation attacks, > rails uses a setting called allow_forgery_detection which was causing > problems with the POST data for the text_field_with_auto_complete, > giving me a "ActionController::InvalidAuthenticityToken" error message > which I was able to find using the Firebug plugin for Firefox. Since > my project doesn''t require any authentication (it''s just a giant free > database) I just added the line > > self.allow_forgery_protection = false > > into my application.rb file. Everything works now as it should. Thanks > for the help! > > On Jan 7, 6:06 am, "Nicolás Sanguinetti" <godf...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Do you have <%= javascript_include_tag :defaults %> in your layout > > inside the <head> tag? > > > > Best, > > -Nicolas > > > > > On Jan 7, 2008 6:26 AM, damien <Mike.Pyro...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > I''m using Rails 2.0 and installed the plug-in for auto-complete. > > > > > The page shows up fine... the problem is that the > > > text_field_with_auto_complete in the view doesn''t actually auto- > > > complete. Since I hand populated the database I know what to search > > > for, but it just won''t show me any suggestions. > > > > > If someone might be able to point out what I''m doing wrong I''d greatly > > > appreciate it. Below are some code snippets from my very basic > > > project. > > > > > #VIEW _search.html.erb > > > <H3>Search for Your Error Message Below</H3> > > > > > <%= text_field_with_auto_complete :solution, :error_name %> > > > > > #VIEW index.html.erb > > > <H1>Welcome to the Solutions Lookup Database</H1> > > > > > <%= render :partial => ''search'' %> > > > > > #CONTROLLER solutions_controller.rb > > > class SolutionsController < ApplicationController > > > auto_complete_for :solution, :error_name > > > def index > > > > > end > > > def search > > > :partial > > > end > > > end > > > > > #MIGRATION 002_testpopulationsolutions.rb > > > class Testpopulatesolutions < ActiveRecord::Migration > > > def self.up > > > Solution.create :error_name => "404", :description => "Website could > > > not be found.", :solution_steps => "Contact admin." > > > Solution.create :error_name => "ip conflict", :description => "Your > > > computer has the same network address as another.", :solution_steps => > > > "Contact admin." > > > Solution.create :error_name => "computer restarts", :description => > > > "Computer is most likely overheating.", :solution_steps => "Blow out > > > vents with compressed duster." > > > end > > > > > def self.down > > > drop_table :solutions > > > create_table :solutions do |t| > > > t.column :error_name, :string > > > t.column :description, :text > > > t.column :solution_steps, :text > > > end > > > end > > > end > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Tomek
2008-Jan-18 13:48 UTC
Re: text_field_with_auto_complete does not actually auto complete
You make it in a wrong way... Sending requests (for autocompleting results) via POSTs in RESTful app and disabling forgery_protection isn''t good solution IMO. You must force javascript to send request via GETs not POSTs. you can make it by adding {:method => :get} option, i.e: <%= text_field_with_auto_complete :solution, :error_name, {}, {:method => :get} %> In routes.rb you just add: map.resources :solutions, :collection => {:auto_complete_for_error_name => :get } more here: http://trix.pl/blog/ruby-on-rails/auto-complete-for-rails-2-0-tutorial --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---