I''m trying to get something similar to example2 in the following link working: http://jnylund.typepad.com/joels_blog/2008/02/ajax-rails-face.html I have defined a function in my AccountsController: def load_accounts_for_contact render :text => "some text here", :layout => false end I have defined the routes for it: map.resources :contacts, :path_prefix => "/users/:user_id", :name_prefix => "user_" do |contact| contact.resources :accounts, :collection => { :load_accounts_for_contact => :get } end In my view I have: <script type="text/javascript"/> function updateAccountOptions() { var contact_select = $(''contact_id''); var url = ''http://web1.tunnlr.com:10143/users/<%= @user.to_param %>/contacts/'' + contact_select.getChildNodes()[contact_select.getSelectedIndex()].getValue() + ''/accounts/load_accounts_for_contact''; var ajax = new Ajax(); ajax.responseType = Ajax.FBML; ajax.requireLogin = true; ajax.ondone = function(data) { document.getElementById(''test_account'').setInnerFBML(data); } ajax.post(url); } </script>>From firebug I can see that the url built is correct and if I copy itdirectly into the browser, I can get the rendered text (some text here). But the ajax call causes an exception as if the routes couldn''t be found: Processing ApplicationController#index (for 127.0.0.1 at 2008-10-28 22:48:15) [POST] Session ID: 1b06418b3bbb49125147af6a-617977441 Parameters: {"fb_sig_time"=>"1225259294.7547", "fb_sig"=>"62540514b667f921ca9b2ba59d33ceb6", "fb_sig_in_new_facebook"=>"1", "fb_sig_locale"=>"en_US", "fb_sig_session_key"=>"1b06418b3bbb49125147af6a-617977441", "fb_sig_expires"=>"1225345694", "fb_sig_added"=>"1", "fb_sig_is_ajax"=>"1", "fb_sig_api_key"=>"xxxxxx", "fb_sig_user"=>"xxxxx", "fb_sig_profile_update_time"=>"1218210790"} ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.): /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/routing/recognition_optimisation.rb:65:in `recognize_path'' /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/routing/route_set.rb:384:in `recognize'' /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:148:in `handle_request'' /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:107:in `dispatch'' /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:104:in `synchronize'' /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:104:in `dispatch'' /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:120:in `dispatch_cgi'' /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/l I''m not sure what is wrong here, so any insight will be greatly appreciated. -- Zhao
Have you tried restarting mongrel on your server after adding the new routes? On Oct 28, 2008, at 11:01 PM, Zhao Lu wrote:> I''m trying to get something similar to example2 in the following > link working: > http://jnylund.typepad.com/joels_blog/2008/02/ajax-rails-face.html > > I have defined a function in my AccountsController: > > def load_accounts_for_contact > render :text => "some text here", :layout => false > end > > I have defined the routes for it: > map.resources :contacts, :path_prefix => "/users/:user_id", > :name_prefix => "user_" do |contact| > contact.resources :accounts, :collection => { > :load_accounts_for_contact => :get } > end > > In my view I have: > > <script type="text/javascript"/> > function updateAccountOptions() { > var contact_select = $(''contact_id''); > var url = ''http://web1.tunnlr.com:10143/users/<%= @user.to_param > %>/contacts/'' + > contact_select.getChildNodes() > [contact_select.getSelectedIndex()].getValue() > + ''/accounts/load_accounts_for_contact''; > var ajax = new Ajax(); > ajax.responseType = Ajax.FBML; > ajax.requireLogin = true; > ajax.ondone = function(data) { > document.getElementById(''test_account'').setInnerFBML(data); > } > > ajax.post(url); > } > </script> > >> From firebug I can see that the url built is correct and if I copy it > directly into the browser, I can get the rendered text (some text > here). > But the ajax call causes an exception as if the routes couldn''t be > found: > > Processing ApplicationController#index (for 127.0.0.1 at 2008-10-28 > 22:48:15) [POST] > Session ID: 1b06418b3bbb49125147af6a-617977441 > Parameters: {"fb_sig_time"=>"1225259294.7547", > "fb_sig"=>"62540514b667f921ca9b2ba59d33ceb6", > "fb_sig_in_new_facebook"=>"1", "fb_sig_locale"=>"en_US", > "fb_sig_session_key"=>"1b06418b3bbb49125147af6a-617977441", > "fb_sig_expires"=>"1225345694", "fb_sig_added"=>"1", > "fb_sig_is_ajax"=>"1", "fb_sig_api_key"=>"xxxxxx", > "fb_sig_user"=>"xxxxx", "fb_sig_profile_update_time"=>"1218210790"} > > > ActionController::MethodNotAllowed (Only get, put, and delete requests > are allowed.): > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/ > action_controller/routing/recognition_optimisation.rb:65:in > `recognize_path'' > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/ > action_controller/routing/route_set.rb:384:in > `recognize'' > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/ > action_controller/dispatcher.rb:148:in > `handle_request'' > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/ > action_controller/dispatcher.rb:107:in > `dispatch'' > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/ > action_controller/dispatcher.rb:104:in > `synchronize'' > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/ > action_controller/dispatcher.rb:104:in > `dispatch'' > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/ > action_controller/dispatcher.rb:120:in > `dispatch_cgi'' > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/l > > I''m not sure what is wrong here, so any insight will be greatly > appreciated. > > -- > Zhao > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/facebooker-talk
Since you''re not using the Ajax.Updater from facebooker.js you need to tell it the _method since by default everything facebook sends you is a POST (or change your route to allow the post). Instead of ajax.post(url); do params = {''_method'':''GET''} ajax.post(url, params); Take a look @ the facebooker.js to see which routines from prototype/scriptaculous have been overriden to work in facebook. Eliminating layers between fan and creator, publisher and retailer http://PullBot.com/ http://Kekova.ca/ http://ChrisNolan.ca/ On Wed, Oct 29, 2008 at 02:01, Zhao Lu <zhao.lu.us at gmail.com> wrote:> I''m trying to get something similar to example2 in the following link > working: > http://jnylund.typepad.com/joels_blog/2008/02/ajax-rails-face.html > > I have defined a function in my AccountsController: > > def load_accounts_for_contact > render :text => "some text here", :layout => false > end > > I have defined the routes for it: > map.resources :contacts, :path_prefix => "/users/:user_id", > :name_prefix => "user_" do |contact| > contact.resources :accounts, :collection => { > :load_accounts_for_contact => :get } > end > > In my view I have: > > <script type="text/javascript"/> > function updateAccountOptions() { > var contact_select = $(''contact_id''); > var url = ''http://web1.tunnlr.com:10143/users/<%= @user.to_param > %>/contacts/'' + > > contact_select.getChildNodes()[contact_select.getSelectedIndex()].getValue() > + ''/accounts/load_accounts_for_contact''; > var ajax = new Ajax(); > ajax.responseType = Ajax.FBML; > ajax.requireLogin = true; > ajax.ondone = function(data) { > document.getElementById(''test_account'').setInnerFBML(data); > } > > ajax.post(url); > } > </script> > > >From firebug I can see that the url built is correct and if I copy it > directly into the browser, I can get the rendered text (some text > here). > But the ajax call causes an exception as if the routes couldn''t be found: > > Processing ApplicationController#index (for 127.0.0.1 at 2008-10-28 > 22:48:15) [POST] > Session ID: 1b06418b3bbb49125147af6a-617977441 > Parameters: {"fb_sig_time"=>"1225259294.7547", > "fb_sig"=>"62540514b667f921ca9b2ba59d33ceb6", > "fb_sig_in_new_facebook"=>"1", "fb_sig_locale"=>"en_US", > "fb_sig_session_key"=>"1b06418b3bbb49125147af6a-617977441", > "fb_sig_expires"=>"1225345694", "fb_sig_added"=>"1", > "fb_sig_is_ajax"=>"1", "fb_sig_api_key"=>"xxxxxx", > "fb_sig_user"=>"xxxxx", "fb_sig_profile_update_time"=>"1218210790"} > > > ActionController::MethodNotAllowed (Only get, put, and delete requests > are allowed.): > > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/routing/recognition_optimisation.rb:65:in > `recognize_path'' > > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/routing/route_set.rb:384:in > `recognize'' > > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:148:in > `handle_request'' > > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:107:in > `dispatch'' > > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:104:in > `synchronize'' > > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:104:in > `dispatch'' > > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:120:in > `dispatch_cgi'' > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/l > > I''m not sure what is wrong here, so any insight will be greatly > appreciated. > > -- > Zhao > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/facebooker-talk >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/facebooker-talk/attachments/20081029/e99ed29c/attachment.html>
My apologies. Not careful enough about reading the fact that things were rendering & it appears that my mail queue is running about 20 hours behind due to a massive spam flood. On Oct 28, 2008, at 11:01 PM, Zhao Lu wrote:> I''m trying to get something similar to example2 in the following > link working: > http://jnylund.typepad.com/joels_blog/2008/02/ajax-rails-face.html > > I have defined a function in my AccountsController: > > def load_accounts_for_contact > render :text => "some text here", :layout => false > end > > I have defined the routes for it: > map.resources :contacts, :path_prefix => "/users/:user_id", > :name_prefix => "user_" do |contact| > contact.resources :accounts, :collection => { > :load_accounts_for_contact => :get } > end > > In my view I have: > > <script type="text/javascript"/> > function updateAccountOptions() { > var contact_select = $(''contact_id''); > var url = ''http://web1.tunnlr.com:10143/users/<%= @user.to_param > %>/contacts/'' + > contact_select.getChildNodes() > [contact_select.getSelectedIndex()].getValue() > + ''/accounts/load_accounts_for_contact''; > var ajax = new Ajax(); > ajax.responseType = Ajax.FBML; > ajax.requireLogin = true; > ajax.ondone = function(data) { > document.getElementById(''test_account'').setInnerFBML(data); > } > > ajax.post(url); > } > </script> > >> From firebug I can see that the url built is correct and if I copy it > directly into the browser, I can get the rendered text (some text > here). > But the ajax call causes an exception as if the routes couldn''t be > found: > > Processing ApplicationController#index (for 127.0.0.1 at 2008-10-28 > 22:48:15) [POST] > Session ID: 1b06418b3bbb49125147af6a-617977441 > Parameters: {"fb_sig_time"=>"1225259294.7547", > "fb_sig"=>"62540514b667f921ca9b2ba59d33ceb6", > "fb_sig_in_new_facebook"=>"1", "fb_sig_locale"=>"en_US", > "fb_sig_session_key"=>"1b06418b3bbb49125147af6a-617977441", > "fb_sig_expires"=>"1225345694", "fb_sig_added"=>"1", > "fb_sig_is_ajax"=>"1", "fb_sig_api_key"=>"xxxxxx", > "fb_sig_user"=>"xxxxx", "fb_sig_profile_update_time"=>"1218210790"} > > > ActionController::MethodNotAllowed (Only get, put, and delete requests > are allowed.): > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/ > action_controller/routing/recognition_optimisation.rb:65:in > `recognize_path'' > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/ > action_controller/routing/route_set.rb:384:in > `recognize'' > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/ > action_controller/dispatcher.rb:148:in > `handle_request'' > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/ > action_controller/dispatcher.rb:107:in > `dispatch'' > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/ > action_controller/dispatcher.rb:104:in > `synchronize'' > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/ > action_controller/dispatcher.rb:104:in > `dispatch'' > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/ > action_controller/dispatcher.rb:120:in > `dispatch_cgi'' > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/l > > I''m not sure what is wrong here, so any insight will be greatly > appreciated. > > -- > Zhao > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/facebooker-talk
Yep, my other posting about link_to_remote had the same problem with not defining _method (I defined method without the underscore). I should have looked at facebooker.js to begin with but it didn''t cross my mind. Thanks Chris! Zhao On Wed, Oct 29, 2008 at 5:43 PM, Chris Nolan.ca <chrisnolan.ca+rubyforge at gmail.com> wrote:> Since you''re not using the Ajax.Updater from facebooker.js you need to tell > it the _method since by default everything facebook sends you is a POST (or > change your route to allow the post). > > Instead of > > ajax.post(url); > > do > > params = {''_method'':''GET''} > ajax.post(url, params); > > Take a look @ the facebooker.js to see which routines from > prototype/scriptaculous have been overriden to work in facebook. > > Eliminating layers between fan and creator, publisher and retailer > http://PullBot.com/ > http://Kekova.ca/ > http://ChrisNolan.ca/ > > > On Wed, Oct 29, 2008 at 02:01, Zhao Lu <zhao.lu.us at gmail.com> wrote: >> >> I''m trying to get something similar to example2 in the following link >> working: >> http://jnylund.typepad.com/joels_blog/2008/02/ajax-rails-face.html >> >> I have defined a function in my AccountsController: >> >> def load_accounts_for_contact >> render :text => "some text here", :layout => false >> end >> >> I have defined the routes for it: >> map.resources :contacts, :path_prefix => "/users/:user_id", >> :name_prefix => "user_" do |contact| >> contact.resources :accounts, :collection => { >> :load_accounts_for_contact => :get } >> end >> >> In my view I have: >> >> <script type="text/javascript"/> >> function updateAccountOptions() { >> var contact_select = $(''contact_id''); >> var url = ''http://web1.tunnlr.com:10143/users/<%= @user.to_param >> %>/contacts/'' + >> >> contact_select.getChildNodes()[contact_select.getSelectedIndex()].getValue() >> + ''/accounts/load_accounts_for_contact''; >> var ajax = new Ajax(); >> ajax.responseType = Ajax.FBML; >> ajax.requireLogin = true; >> ajax.ondone = function(data) { >> document.getElementById(''test_account'').setInnerFBML(data); >> } >> >> ajax.post(url); >> } >> </script> >> >> >From firebug I can see that the url built is correct and if I copy it >> directly into the browser, I can get the rendered text (some text >> here). >> But the ajax call causes an exception as if the routes couldn''t be found: >> >> Processing ApplicationController#index (for 127.0.0.1 at 2008-10-28 >> 22:48:15) [POST] >> Session ID: 1b06418b3bbb49125147af6a-617977441 >> Parameters: {"fb_sig_time"=>"1225259294.7547", >> "fb_sig"=>"62540514b667f921ca9b2ba59d33ceb6", >> "fb_sig_in_new_facebook"=>"1", "fb_sig_locale"=>"en_US", >> "fb_sig_session_key"=>"1b06418b3bbb49125147af6a-617977441", >> "fb_sig_expires"=>"1225345694", "fb_sig_added"=>"1", >> "fb_sig_is_ajax"=>"1", "fb_sig_api_key"=>"xxxxxx", >> "fb_sig_user"=>"xxxxx", "fb_sig_profile_update_time"=>"1218210790"} >> >> >> ActionController::MethodNotAllowed (Only get, put, and delete requests >> are allowed.): >> >> /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/routing/recognition_optimisation.rb:65:in >> `recognize_path'' >> >> /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/routing/route_set.rb:384:in >> `recognize'' >> >> /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:148:in >> `handle_request'' >> >> /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:107:in >> `dispatch'' >> >> /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:104:in >> `synchronize'' >> >> /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:104:in >> `dispatch'' >> >> /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:120:in >> `dispatch_cgi'' >> /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/l >> >> I''m not sure what is wrong here, so any insight will be greatly >> appreciated. >> >> -- >> Zhao >> _______________________________________________ >> Facebooker-talk mailing list >> Facebooker-talk at rubyforge.org >> http://rubyforge.org/mailman/listinfo/facebooker-talk > >-- Zhao
You can add &_method=get to the URL to force a GET request. On Wed, Oct 29, 2008 at 1:01 AM, Zhao Lu <zhao.lu.us at gmail.com> wrote:> I''m trying to get something similar to example2 in the following link working: > http://jnylund.typepad.com/joels_blog/2008/02/ajax-rails-face.html > > I have defined a function in my AccountsController: > > def load_accounts_for_contact > render :text => "some text here", :layout => false > end > > I have defined the routes for it: > map.resources :contacts, :path_prefix => "/users/:user_id", > :name_prefix => "user_" do |contact| > contact.resources :accounts, :collection => { > :load_accounts_for_contact => :get } > end > > In my view I have: > > <script type="text/javascript"/> > function updateAccountOptions() { > var contact_select = $(''contact_id''); > var url = ''http://web1.tunnlr.com:10143/users/<%= @user.to_param > %>/contacts/'' + > contact_select.getChildNodes()[contact_select.getSelectedIndex()].getValue() > + ''/accounts/load_accounts_for_contact''; > var ajax = new Ajax(); > ajax.responseType = Ajax.FBML; > ajax.requireLogin = true; > ajax.ondone = function(data) { > document.getElementById(''test_account'').setInnerFBML(data); > } > > ajax.post(url); > } > </script> > > >From firebug I can see that the url built is correct and if I copy it > directly into the browser, I can get the rendered text (some text > here). > But the ajax call causes an exception as if the routes couldn''t be found: > > Processing ApplicationController#index (for 127.0.0.1 at 2008-10-28 > 22:48:15) [POST] > Session ID: 1b06418b3bbb49125147af6a-617977441 > Parameters: {"fb_sig_time"=>"1225259294.7547", > "fb_sig"=>"62540514b667f921ca9b2ba59d33ceb6", > "fb_sig_in_new_facebook"=>"1", "fb_sig_locale"=>"en_US", > "fb_sig_session_key"=>"1b06418b3bbb49125147af6a-617977441", > "fb_sig_expires"=>"1225345694", "fb_sig_added"=>"1", > "fb_sig_is_ajax"=>"1", "fb_sig_api_key"=>"xxxxxx", > "fb_sig_user"=>"xxxxx", "fb_sig_profile_update_time"=>"1218210790"} > > > ActionController::MethodNotAllowed (Only get, put, and delete requests > are allowed.): > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/routing/recognition_optimisation.rb:65:in > `recognize_path'' > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/routing/route_set.rb:384:in > `recognize'' > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:148:in > `handle_request'' > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:107:in > `dispatch'' > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:104:in > `synchronize'' > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:104:in > `dispatch'' > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:120:in > `dispatch_cgi'' > /Users/zlu/.gem/ruby/1.8/gems/actionpack-2.1.1/l > > I''m not sure what is wrong here, so any insight will be greatly appreciated. > > -- > Zhao > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/facebooker-talk >