[Facebooker-talk] fb_comments and fb_board not working
Mike Mangino
mmangino at elevatedrails.com
Wed Sep 10 07:31:27 EDT 2008
There is no HTTP support for the PUT or DELETE verbs, so Rails uses
_method=PUT or _method=DELETE as a workaround. When rails receives a
POST request, it looks for a _method parameter. If one exists, it uses
the verb specified in that parameter for routing.
Mike
On Sep 9, 2008, at 11:49 PM, Allen Walker wrote:
> Sorry for the multiple posts..
>
> Finally if you wish you CAN use the helper:
>
> <%=fb_comments("comments_for_comment_lesson", true, true,
> 20,:showform => true, :title => "Comment Lesson
> Comments", :callbackurl => url_for(:controller =>
> "home", :action=>"index", :only_path => false, :_method => :get)) %>
>
> Now can you explain to me why this works? You write some text into
> the facebook generated comments form. It sends an HTTP POST .
> My :controller=>"home" :action=>"index" has no rule for HTTP POSTS
> that I see. I'm just really confused at to what exactly is going on
> here.
>
> Allen Walker wrote:
>> The following DOES work:
>>
>> <fb:comments xid="my_wall" callbackurl="<%= url_for(:controller =>
>> "home", :action=>"index", :only_path => false, :_method => :get)
>> %>"><fb:title>some title</fb:title><fb:comments>
>>
>> Allen Walker wrote:
>>> I tried the following it posts don't take:
>>>
>>> <fb:comments xid="my_wall" callbackurl="<%= url_for(:controller =>
>>> "home", :action=>"index", :only_path => false, :conditions =>
>>> {:_method => :get}) %>"><fb:title>some title</fb:title><fb:comments>
>>>
>>> Jonathan Otto wrote:
>>>> Here is the exact code:
>>>>
>>>> <fb:comments xid="my_wall" callbackurl="<%= user_url
>>>> @user, :_method
>>>> => :get %>"><fb:title>some title</fb:title><fb:comments>
>>>>
>>>> On Mon, Sep 8, 2008 at 12:27 AM, Jonathan Otto <jonathan.otto at gmail.com
>>>> > wrote:
>>>>
>>>>> just add the _method parameter to your URL for the callback
>>>>> parameter
>>>>> (you need to specify it), this will force rails to interpret the
>>>>> request as GET. for example, a RESTful URL works like so:
>>>>>
>>>>> user_url @user, :_method => :get
>>>>>
>>>>>
>>>>> On Fri, Sep 5, 2008 at 12:50 AM, Allen Walker
>>>>> <auswalk at gmail.com> wrote:
>>>>>
>>>>>> Yeah I'm not really sure. Apparently I need to immerse myself
>>>>>> in REST wrt
>>>>>> Rails. I'm pretty confused I guess. Running "rake routes" can
>>>>>> cause
>>>>>> additional confusion sometimes.
>>>>>>
>>>>>> The thing to understand with the problem here is that the URL
>>>>>> has to accept
>>>>>> POST requests. /controller/new does by the REST definition...
>>>>>> and therefore
>>>>>> will work with the fb:comments tag. /controller by itself
>>>>>> won't accept a
>>>>>> POST and therefore won't work with the fb:comments tag.
>>>>>>
>>>>>> Right now I'm so confused that any page I put a fb:comments or
>>>>>> fb:board on I
>>>>>> make sure is /controller/new . But that is not really ideal.
>>>>>>
>>>>>> Ken Schroeder wrote:
>>>>>>
>>>>>>> Been following along with your thread here as I've had the
>>>>>>> same exact
>>>>>>> issue. So what did you add in your routes for your
>>>>>>> /article/8 example which I assume is the show path.
>>>>>>>
>>>>>>> Using Mikes example of map.fancy_name 'fancy_path/:id' ....
>>>>>>> didn't quite
>>>>>>> undetstand how to input that correctly.
>>>>>>>
>>>>>>> On Thu, Sep 4, 2008 at 6:26 PM, Allen Walker <auswalk at gmail.com
>>>>>>> <mailto:auswalk at gmail.com>> wrote:
>>>>>>>
>>>>>>> That's what I figured and that makes perfect sense. Thanks for
>>>>>>> clearing that up. you might want to put this in your book btw.
>>>>>>>
>>>>>>> Best regards
>>>>>>>
>>>>>>>
>>>>>>> Mike Mangino wrote:
>>>>>>>
>>>>>>> Actually, you can
>>>>>>>
>>>>>>> map.fancy_name 'fancy_path/:id' ....
>>>>>>>
>>>>>>> Your problems were caused by Facebook sending a POST
>>>>>>> request
>>>>>>> to a URL that doesn't support posts. When they try to do
>>>>>>> that,
>>>>>>> your application returns an error and they cancel the
>>>>>>> posting.
>>>>>>> By creating a route by hand, you are decoupling it from
>>>>>>> the
>>>>>>> HTTP method used.
>>>>>>>
>>>>>>> Mike
>>>>>>>
>>>>>>> On Sep 4, 2008, at 6:16 PM, Allen Walker wrote:
>>>>>>>
>>>>>>> Also even though this works, i have urls that are
>>>>>>> dynamic
>>>>>>> , i.e. /articles/8 for example and want comments on
>>>>>>> those
>>>>>>> pages. That doesn't work. And I can't hardcode a
>>>>>>> route for
>>>>>>> a dynamic route that I know of really.
>>>>>>>
>>>>>>> Mike Mangino wrote:
>>>>>>>
>>>>>>> Try creating a route just for that page, i.e.
>>>>>>>
>>>>>>> route.discussion_board 'discussion',
>>>>>>> :controller=>"home", :action=>"index"
>>>>>>>
>>>>>>> Then, go to
>>>>>>> http://apps.new.facebook.com/myapp/discussion
>>>>>>> and see
>>>>>>> if that works.
>>>>>>>
>>>>>>> I struggled like mad to get this to work the first
>>>>>>> time too. I wish I could remember the eventual
>>>>>>> fix.
>>>>>>>
>>>>>>> Mike
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Facebooker-talk mailing list
>>>>>>> Facebooker-talk at rubyforge.org
>>>>>>> <mailto:Facebooker-talk at rubyforge.org>
>>>>>>> http://rubyforge.org/mailman/listinfo/facebooker-talk
>>>>>>>
>>>>>>>
>>>>>>> -- Mike Mangino
>>>>>>> http://www.elevatedrails.com
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Facebooker-talk mailing list
>>>>>>> Facebooker-talk at rubyforge.org <mailto:Facebooker-talk at rubyforge.org
>>>>>>> >
>>>>>>> http://rubyforge.org/mailman/listinfo/facebooker-talk
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> _______________________________________________
>>>>>> Facebooker-talk mailing list
>>>>>> Facebooker-talk at rubyforge.org
>>>>>> http://rubyforge.org/mailman/listinfo/facebooker-talk
>>>>>>
>>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
> _______________________________________________
> Facebooker-talk mailing list
> Facebooker-talk at rubyforge.org
> http://rubyforge.org/mailman/listinfo/facebooker-talk
--
Mike Mangino
http://www.elevatedrails.com
More information about the Facebooker-talk
mailing list