Hi everyone, My development team is using facebooker to develop a simple questionnaire for distribution via facebook, as part of a research project we''re involved with. In order to store survey responses for research purposes, we elected to scaffold survey_responses and then work from there. As part of our setup, we modified routes.rb as follows: ActionController::Routing::Routes.draw do |map| map.resources :survey_responses, :conditions => {:canvas => true} # The priority is based upon order of creation: first created -> highest priority. ..... map.root :controller => "survey_responses", :action => ''new'' Once we turned on the server and visited http://apps.facebook.com/stem_survey two errors surfaced in facebook: " urlexception unable to parse URL /http://apps.facebooker.com/stem_survey//survey_responses/new " and a second error related to fb:editor. Inside new.fmbl.erb: <% facebook_form_for(@survey_response) do |f| %> we changed to <% facebook_form_for(:survey_response, at survey_response,:url => ''/ stem_survey/survey_responses/create'', :labelwidth => ''75'', :width => ''500'') do |f| %> Which seemed to correct the fb:editor problems, but still caused incorrect url parsing upon creation of a survey record. To resolve this, we changed the survey_responses_controller to: respond_to do |format| if @survey_response.save flash[:notice] = ''SurveyResponse was successfully created.'' format.html { redirect_to(@survey_response) } format.fbml { redirect_to(''http://apps.facebook.com/stem_survey/survey_responses/''+ at survey_response.id.to_s) } format.xml { render :xml => @survey_response, :status => :created, :location => @survey_response } Is there a more elegant solution to using scaffolding in a facebooker- based application? Thanks in advance, ================ Kate Dohe HNLC Staff email: dohe at hawaii.edu cell phone: 417.773.4876 office: POST 309, University of Hawai''i at Manoa -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/facebooker-talk/attachments/20081101/f94f2dae/attachment.html>
Le 2 nov. 08 ? 03:29, Kate Dohe a ?crit :> Once we turned on the server and visited http://apps.facebook.com/stem_survey > two errors surfaced in facebook: > " urlexception unable to parse URL /http://apps.facebooker.com/stem_survey//survey_responses/new > "Did you correctly fill the Facebooker config file ? The canvas_page_name has to be the name of the application registered in facebook, without any trailing shlash. For you I guess it should be ''stem_survey''.> format.fbml { redirect_to(''http://apps.facebook.com/stem_survey/survey_responses/''+ at survey_response.id.to_s) > }If the canvas_page_name field is correctly set, you should be able to do : redirect_to(@survey_response, :canvas => true) HTH, -- St?phane Akkaoui
Hi Stephane St?phane Akkaoui wrote:> > Le 2 nov. 08 ? 03:29, Kate Dohe a ?crit : >> Once we turned on the server and visited >> http://apps.facebook.com/stem_survey two errors surfaced in facebook: >> " urlexception unable to parse URL >> /http://apps.facebooker.com/stem_survey//survey_responses/new" > > Did you correctly fill the Facebooker config file ? > The canvas_page_name has to be the name of the application registered > in facebook, without any trailing shlash. For you I guess it should be > ''stem_survey''.we removed the trailing slash: canvas_page_name: http://apps.facebook.com/stem_survey> >> format.fbml { >> redirect_to(''http://apps.facebook.com/stem_survey/survey_responses/''+ at survey_response.id.to_s) } >> > > If the canvas_page_name field is correctly set, you should be able to > do : redirect_to(@survey_response, :canvas => true)Did that, but got this error: ArgumentError in Survey responsesController#create wrong number of arguments (2 for 1) RAILS_ROOT: /home/srjoseph/stem_survey Application Trace | Framework Trace | Full Trace vendor/plugins/facebooker/lib/facebooker/rails/controller.rb:154:in `fbml_redirect_tag'' vendor/plugins/facebooker/lib/facebooker/rails/controller.rb:154:in `redirect_to'' app/controllers/survey_responses_controller.rb:52:in `create'' /var/lib/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/mime_responds.rb:131:in `call'' /var/lib/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/mime_responds.rb:131:in `custom'' /var/lib/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/mime_responds.rb:160:in `call'' /var/lib/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/mime_responds.rb:160:in `respond'' /var/lib/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/mime_responds.rb:154:in `each'' /var/lib/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/mime_responds.rb:154:in `respond'' /var/lib/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/mime_responds.rb:107:in `respond_to'' app/controllers/survey_responses_controller.rb:48:in `create'' /var/lib/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/base.rb:1166:in `send'' /var/lib/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/base.rb:1166:in `perform_action_without_filters'' /var/lib/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/filters.rb:579:in `call_filters'' /var/lib/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/filters.rb:572:in `perform_action_without_benchmark'' /var/lib/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'' /var/lib/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'' /var/lib/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/rescue.rb:201:in `perform_action_without_caching'' /var/lib/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/caching/sql_cache.rb:13:in `perform_action'' /var/lib/gems/1.8/gems/activerecord-2.1.1/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'' /var/lib/gems/1.8/gems/activerecord-2.1.1/lib/active_record/query_cache.rb:8:in `cache'' /var/lib/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/caching/sql_cache.rb:12:in `perform_action'' /var/lib/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/base.rb:529:in `send'' /var/lib/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/base.rb:529:in `process_without_filters'' /var/lib/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/filters.rb:568:in `process_without_session_management_support'' /var/lib/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/session_management.rb:130:in `process'' /var/lib/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/base.rb:389:in `process'' /var/lib/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:503:in `load'' /var/lib/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:503:in `load'' /var/lib/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:355:in `new_constants_in'' /var/lib/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:503:in `load'' /var/lib/gems/1.8/gems/rails-2.1.1/lib/commands/servers/mongrel.rb:64 /var/lib/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:510:in `require'' /var/lib/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:355:in `new_constants_in'' /var/lib/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:510:in `require'' /var/lib/gems/1.8/gems/rails-2.1.1/lib/commands/server.rb:39 Any ideas? Many thanks in advance CHEERS> SAM -- Sam Joseph, Ph.D. Co-Director Laboratory for Interactive Learning Technologies Department of Information and Computer Sciences University of Hawaii
Hi Sam, Soory for the delay... you may have fix your problem now. But still, i give you some answers, they could be interesting for others to. Le 3 nov. 08 ? 21:35, Sam Joseph a ?crit :> we removed the trailing slash: > canvas_page_name: http://apps.facebook.com/stem_surveyThe canvas page name is not an url. It''s juste a name. As I told you before, for your app, it''s : canvas_page_name: stem_survey>>> format.fbml { redirect_to(''http://apps.facebook.com/stem_survey/survey_responses/''+ at survey_response.id.to_s) >>> } >> >> If the canvas_page_name field is correctly set, you should be able >> to do : redirect_to(@survey_response, :canvas => true) > Did that, but got this error: > > ArgumentError in Survey responsesController#create > > wrong number of arguments (2 for 1)Here is an example : # in config/root.rb map.resources :messages # in script/console >> app.messages_url() => "http://www.example.com/messages" >> app.messages_url(:canvas => true) => "http://apps.new.facebook.com/alisterapptrois/messages" >> @message = Message.find(:first) => #<Message id: 29, user_id: 1278968509, body: "coucou les gens", page_uid: 26149797103, created_at: "2008-10-16 13:59:04", updated_at: "2008-10-16 13:59:04"> >> app.message_url(@message, :canvas => true) => "http://apps.new.facebook.com/canvas_page_name/messages/29" >> app.message_url(@message, :canvas => false) => "http://www.example.com/messages/29" >> app.message_url(@message) => "http://www.example.com/messages/29" # in app/controller/hello_controller def foo @message = Message.find(:first) redirect_to( message_url(@message, :canvas => true)) end # in script/server (logs after calling http://localhost:3000/hello/toto) Processing HelloController#toto (for 127.0.0.1 at 2008-11-07 13:03:53) [GET] Session ID: 3c6050ab0cfc62d75ddc7a1441792271 Parameters: {"action"=>"toto", "controller"=>"hello"} Message Load (0.000276) SELECT * FROM `messages` LIMIT 1 Message Columns (0.002220) SHOW FIELDS FROM `messages` Redirected to http://apps.new.facebook.com/canvas_page_name/messages/29 Completed in 0.00896 (111 reqs/sec) | DB: 0.00312 (34%) | 302 Found [http://localhost/hello/toto ] # in app/controller/hello_controller def foo @message = Message.find(:first) redirect_to( message_url(@message)) end # in script/server (logs after calling http://localhost:3000/hello/toto) Processing HelloController#toto (for 127.0.0.1 at 2008-11-07 13:03:08) [GET] Session ID: 3c6050ab0cfc62d75ddc7a1441792271 Parameters: {"action"=>"toto", "controller"=>"hello"} Message Load (0.000266) SELECT * FROM `messages` LIMIT 1 Message Columns (0.001918) SHOW FIELDS FROM `messages` Redirected to http://localhost:3000/messages/29 Completed in 0.01750 (57 reqs/sec) | DB: 0.00615 (35%) | 302 Found [http://localhost/hello/toto ] HTH, -- St?phane Akkaoui http://www.sociabliz.com (fr) http://imeuble.info (fr)
Hi Stephane, Many thanks for getting back to us - that fixed it. Your help much appreciated CHEERS> SAM St?phane Akkaoui wrote:> Hi Sam, > > Soory for the delay... you may have fix your problem now. > But still, i give you some answers, they could be interesting for > others to. > > Le 3 nov. 08 ? 21:35, Sam Joseph a ?crit : >> we removed the trailing slash: >> canvas_page_name: http://apps.facebook.com/stem_survey > > The canvas page name is not an url. It''s juste a name. > As I told you before, for your app, it''s : > > canvas_page_name: stem_survey > > >>>> format.fbml { >>>> redirect_to(''http://apps.facebook.com/stem_survey/survey_responses/''+ at survey_response.id.to_s) } >>>> >>> >>> If the canvas_page_name field is correctly set, you should be able >>> to do : redirect_to(@survey_response, :canvas => true) >> Did that, but got this error: >> >> ArgumentError in Survey responsesController#create >> >> wrong number of arguments (2 for 1) > > Here is an example : > > # in config/root.rb > map.resources :messages > > # in script/console > >> app.messages_url() > => "http://www.example.com/messages" > >> app.messages_url(:canvas => true) > => "http://apps.new.facebook.com/alisterapptrois/messages" > >> @message = Message.find(:first) > => #<Message id: 29, user_id: 1278968509, body: "coucou les gens", > page_uid: 26149797103, created_at: "2008-10-16 13:59:04", updated_at: > "2008-10-16 13:59:04"> > >> app.message_url(@message, :canvas => true) > => "http://apps.new.facebook.com/canvas_page_name/messages/29" > >> app.message_url(@message, :canvas => false) > => "http://www.example.com/messages/29" > >> app.message_url(@message) > => "http://www.example.com/messages/29" > > # in app/controller/hello_controller > def foo > @message = Message.find(:first) > redirect_to( message_url(@message, :canvas => true)) > end > > # in script/server (logs after calling > http://localhost:3000/hello/toto) > Processing HelloController#toto (for 127.0.0.1 at 2008-11-07 > 13:03:53) [GET] > Session ID: 3c6050ab0cfc62d75ddc7a1441792271 > Parameters: {"action"=>"toto", "controller"=>"hello"} > Message Load (0.000276) SELECT * FROM `messages` LIMIT 1 > Message Columns (0.002220) SHOW FIELDS FROM `messages` > Redirected to > http://apps.new.facebook.com/canvas_page_name/messages/29 > Completed in 0.00896 (111 reqs/sec) | DB: 0.00312 (34%) | 302 > Found [http://localhost/hello/toto] > > # in app/controller/hello_controller > def foo > @message = Message.find(:first) > redirect_to( message_url(@message)) > end > > # in script/server (logs after calling > http://localhost:3000/hello/toto) > Processing HelloController#toto (for 127.0.0.1 at 2008-11-07 > 13:03:08) [GET] > Session ID: 3c6050ab0cfc62d75ddc7a1441792271 > Parameters: {"action"=>"toto", "controller"=>"hello"} > Message Load (0.000266) SELECT * FROM `messages` LIMIT 1 > Message Columns (0.001918) SHOW FIELDS FROM `messages` > Redirected to http://localhost:3000/messages/29 > Completed in 0.01750 (57 reqs/sec) | DB: 0.00615 (35%) | 302 Found > [http://localhost/hello/toto] > > HTH, >-- Sam Joseph, Ph.D. Co-Director Laboratory for Interactive Learning Technologies Department of Information and Computer Sciences University of Hawaii