Joel Nylund
2008-Feb-01 15:29 UTC
[Facebooker-talk] proposed patch for fb_request_form_submit
Hi, according to the Facebook docs, you can add a uid to the fb_request_form_submit button which will pre select the user for the form. So you can do: <fb:request-form action="/my_tasks" method="POST" invite="true" type="MyApp" content="wants to invite you to xyz app"> <fb:request-form-submit uid="FRIENDID" /> </fb:request-form> which will create a button that says "Send Fred MyApp Invitation" # helpers.rb Old code: # Create a submit button for an <fb:request-form> def fb_request_form_submit tag "fb:request-form-submit" end New code: # Create a submit button for an <fb:request-form> # options - you can pass uid & label, see http://wiki.developers.facebook.com/index.php/Fb:request-form-submit for details. def fb_request_form_submit(options={}) tag ("fb:request-form-submit",options) end Usage example: <% content_for("invite_message") do %> wants to blah blah blah. <%= fb_req_choice("Join XYZ ap",url_for(:action => "invite_signup")) %> <% end %> <% fb_request_form("MyApp","invite_message",url_for(:action => "invite_signup")) do %> <%= fb_request_form_submit({:uid => a_pre_determined_friend_id})%> <% end %> Test - This works great for my app! (note im using 1.2.6) , I have no idea how to write a test for a helper, if someone wants to show me, I will do it. thanks Joel
David Clements
2008-Feb-01 17:45 UTC
[Facebooker-talk] proposed patch for fb_request_form_submit
Hey Joel, If you look in rails_integration_test.rb you will see the test for that helper method. def test_fb_request_form_submit assert_equal("<fb:request-form-submit />", at h.fb_request_form_submit) end You can add a couple of tests for the options you are adding. And also, there should be a TODO in the documentation for that method. Can you please update it with your patch? # TODO: uid and label are options on this tag. Thanks, Dave On Feb 1, 2008 8:29 AM, Joel Nylund <jnylund at yahoo.com> wrote:> Hi, according to the Facebook docs, you can add a uid to the > fb_request_form_submit button which will pre select the user for the > form. > > So you can do: > > <fb:request-form action="/my_tasks" method="POST" invite="true" > type="MyApp" content="wants to invite you to xyz app"> > <fb:request-form-submit uid="FRIENDID" /> > </fb:request-form> > > which will create a button that says "Send Fred MyApp Invitation" > > # helpers.rb > Old code: > # Create a submit button for an <fb:request-form> > def fb_request_form_submit > tag "fb:request-form-submit" > end > > New code: > # Create a submit button for an <fb:request-form> > # options - you can pass uid & label, see http://wiki.developers.facebook.com/index.php/Fb:request-form-submit > for details. > def fb_request_form_submit(options={}) > tag ("fb:request-form-submit",options) > end > > Usage example: > <% content_for("invite_message") do %> > wants to blah blah blah. <%= fb_req_choice("Join XYZ > ap",url_for(:action => "invite_signup")) %> > <% end %> > <% fb_request_form("MyApp","invite_message",url_for(:action => > "invite_signup")) do %> > <%= fb_request_form_submit({:uid => a_pre_determined_friend_id})%> > <% end %> > > > Test - This works great for my app! (note im using 1.2.6) , I have no > idea how to write a test for a helper, if someone wants to show me, I > will do it. > > thanks > Joel > > > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/facebooker-talk >
Joel Nylund
2008-Feb-04 21:59 UTC
[Facebooker-talk] proposed patch for fb_request_form_submit
Ok, here are the tests and updated rdoc # Create a submit button for an <fb:request-form> # If the request is for an individual user you can optionally # Provide the user and a label for the request button. # For example # <% content_for("invite_user") do %> # This gets sent in the invite. <%= fb_req_choice("Come join us!","new_invite_path") %> # <% end %> # <% fb_request_form("Invite","invite_user","create_invite_path") do %> # Invite <%= fb_name(@facebook_user.friends.first.id)%> to the party<br /> # <%= fb_request_form_submit(@facebook_user.friends.first.id, "Invite %n") %> # <% end %> # <em>See:</em> http://wiki.developers.facebook.com/index.php/Fb:request-form-submit for options def fb_request_form_submit(options={}) tag("fb:request-form-submit",options) end ************************************************* Tests: def test_fb_request_form_submit_with_uid assert_equal("<fb:request-form-submit uid=\"123456789\" / >", at h.fb_request_form_submit({:uid => "123456789"})) end def test_fb_request_form_submit_with_label assert_equal("<fb:request-form-submit label=\"Send Invite to Joel \" />", at h.fb_request_form_submit({:label => "Send Invite to Joel"})) end def test_fb_request_form_submit_with_uid_and_label assert_equal("<fb:request-form-submit label=\"Send Invite to Joel \" uid=\"123456789\" />", at h.fb_request_form_submit({:uid => "123456789", :label => "Send Invite to Joel"})) end thanks Joel On Feb 1, 2008, at 12:45 PM, David Clements wrote:> Hey Joel, > > If you look in rails_integration_test.rb you will see the test for > that helper method. > > def test_fb_request_form_submit > assert_equal("<fb:request-form-submit / > >", at h.fb_request_form_submit) > end > > You can add a couple of tests for the options you are adding. > > And also, there should be a TODO in the documentation for that method. > Can you please update it with your patch? > > # TODO: uid and label are options on this tag. > > > Thanks, > > Dave > > > On Feb 1, 2008 8:29 AM, Joel Nylund <jnylund at yahoo.com> wrote: >> Hi, according to the Facebook docs, you can add a uid to the >> fb_request_form_submit button which will pre select the user for the >> form. >> >> So you can do: >> >> <fb:request-form action="/my_tasks" method="POST" invite="true" >> type="MyApp" content="wants to invite you to xyz app"> >> <fb:request-form-submit uid="FRIENDID" /> >> </fb:request-form> >> >> which will create a button that says "Send Fred MyApp Invitation" >> >> # helpers.rb >> Old code: >> # Create a submit button for an <fb:request-form> >> def fb_request_form_submit >> tag "fb:request-form-submit" >> end >> >> New code: >> # Create a submit button for an <fb:request-form> >> # options - you can pass uid & label, see http://wiki.developers.facebook.com/index.php/Fb:request-form-submit >> for details. >> def fb_request_form_submit(options={}) >> tag ("fb:request-form-submit",options) >> end >> >> Usage example: >> <% content_for("invite_message") do %> >> wants to blah blah blah. <%= fb_req_choice("Join XYZ >> ap",url_for(:action => "invite_signup")) %> >> <% end %> >> <% fb_request_form("MyApp","invite_message",url_for(:action => >> "invite_signup")) do %> >> <%= fb_request_form_submit({:uid => a_pre_determined_friend_id}) >> %> >> <% end %> >> >> >> Test - This works great for my app! (note im using 1.2.6) , I have >> no >> idea how to write a test for a helper, if someone wants to show me, I >> will do it. >> >> thanks >> Joel >> >> >> _______________________________________________ >> Facebooker-talk mailing list >> Facebooker-talk at rubyforge.org >> http://rubyforge.org/mailman/listinfo/facebooker-talk >>