Using form_tag within FB app and Facebooker routes
Paul Covell
5 posts
|
I am building a search query and so I would like the behavior to be like this:
Products is RESTful, so I also use GET /products/<id>/show &c. routes.rb:
products_controller.rb:
search.fbml.erb:
Generates HTML:
Which, when data is entered, generates a GET to my application (dev log)
Finally leading to the error:
I am open to other ways of doing it, but I do like having the search parameters in the URL for bookmarking/sending to others.
Is there a correct recipe for this behavior? I assume other people are building searches or other form input not directly related to an ActiveRecord object, so I think more treatment would be generally valuable. In this case, it would be nice to know more about what’s going on under the hood in Facebooker—I know that it is doing some magic to make RESTful routes work in the first place. My next stop is to read the code, but I was hoping to avoid this. Thanks for any help. Cheers, |
Paul Covell
5 posts
|
Ok I have solved the IncorrectSignature error explained above. The error can be reproduced by using :method => :get in the form_tag (in my case it was instead an unclosed form tag earlier on causing a get request—but the results are the same). The workaround for getting search terms into the URL seems to be a redirect within the action:
This may be unavoidable given the structure of: Browser < Anyone confirm this? |
Mike Mangino
148 posts
|
I think the problem is in a slightly different place than you think. Your form is generating a POST form. You showed the code:
What you probably want is:
Using By default, |
Paul Covell
5 posts
|
Mike, sorry I wasn’t clear earlier—when I use :method => :get I get the IncorrectSignature exception. I tried your suggestion to verify, and the error is exactly the same. If I remove :method => :get to get the POST method, it works fine (but I don’t get my bookmarkable URLs—if I want those, I can do the redirect trick above, caveat as stated). This is probably some special case not caught in Facebooker, but I am shying away from that code (scary..) Now I’m on to a slightly different topic, still forms-related: I’ve gotten all this to work before with PHP, so I’m familiar with how it should work but I’m having a tough time getting good information on how to do it with Facebooker/Rails: - I’m trying to load a friend’s profile data for viewing and I need a dialog box to select the “target” friend. I successfully coded it up before as a FBJS new Dialog.showChoice(‘Select Target’, choose_target_dialog) with choose_target_dialog as a js-string. Now I’ve got a snag : I need to post to <my-server>/url, not <facebook>/url, but I don’t know how to get that URL. There aren’t any examples anywhere (at least with a bit of Googling) covering this kind of usage AFAICT. Cheers, and thanks again. |
Mike Mangino
148 posts
|
In your previous example, can you provide a simple testcase that gives an invalid signature exception? I’m the maintainer of Facebooker and I’d love to get that fixed. Mike |
Paul Covell
5 posts
|
Mike, I’ve managed to re-create this with a basic installation: rails test views/home/index.fbml.erb:
app/controller/application.rb—added immediately below helper :all ensure_application_is_installed_by_facebook_user ensure_authenticated_to_facebook And then I set up my development server and tunnel as I do with normal development. The error is the same. Also, if I remove the :method => :get, the error does not occur. If you like I can send files to the mailing list or to you on the facebooker-talk list. -Paul |
Mike Mangino
148 posts
|
Yuck. I see the same issue, but I don’t know why. In the short term, I’d say you can just use POSTS for this. I’ll keep trying to figure this out and get it fixed. Mike |
Christopher ...
5 posts
|
I’m having the exact same problem. Let me know if you figure anything out! |
Mike Mangino
148 posts
|
Can you guys report this to the facebooker mailing list? I’m going to keep trying to figure it out, but maybe another couple of eyes would be helpful. Mike |
Paul Covell
5 posts
|
Posting now. |
10 posts, 3 voices
