[Facebooker-talk] Problems with *_path() and *_url() helpers when using Publisher

Mike Mangino mmangino at elevatedrails.com
Mon Apr 7 21:34:21 EDT 2008


_path will always spit out a path. If you want a URL, try using _url

Mike

On Apr 7, 2008, at 6:04 PM, Nick Holland wrote:
> Mike,
>
> We use both singular and non-singular resources in the partials for
> notifications, templatized actions and profiles, they all seem to
> elicit the same problem.
>
> It seems like were getting closer to solving the issue, as *_path()
> now returns the relative path of the resource, but I can't seem to get
> it to spit out an absolute path, without hitting the error "Missing
> host to link to! Please provide :host parameter or set
> default_url_options[:host]".
>
> When I do try using :only_path => false as a parameter to our *_path()
> calls, I get an exception stating that it the default_url_options
> method doesn't exist. The partials can't see the default_url_options
> method from the base class or even from my own class that extends
> Publisher (if I throw it in there as a test).
>
> I appreciate you digging deeper, Mike!
>
> - Nick
>
> On Mon, Apr 7, 2008 at 3:18 PM, Mike Mangino <mmangino at elevatedrails.com 
> > wrote:
>> Does this work for non-singular resources? I always use the plural,  
>> and
>> don't currently have any problems. I'll try to take a look at this  
>> during
>> the week.
>>
>> Mike
>>
>>
>>
>> On Apr 7, 2008, at 5:13 PM, Nick Holland wrote:
>>
>>> Hi Christopher,
>>>
>>> We are running Rails 2.0.2, so unfortunately that doesn't seem to be
>>> the issue... but hopefully we are experiencing the same issue,
>>> regardless of the rails version so we both can get it resolved!
>>>
>>> Take care,
>>> Nick Holland
>>>
>>> On Mon, Apr 7, 2008 at 1:48 PM, Christopher Bailey <chris at cobaltedge.com 
>>> >
>> wrote:
>>>
>>>> Nick, what version of Rails are you using?  I've run into issues  
>>>> in this
>>>> same area under Rails 1.2.x.  My app will be moved to Rails 2 in  
>>>> the
>> future,
>>>> but it's a serious undertaking for us, so I haven't been able to  
>>>> move it
>> and
>>>> test out whether Rails 2 solves these problems.  Thus, I'm  
>>>> interested to
>>>> know your Rails version and if that may play into it or not.
>>>>
>>>>
>>>>
>>>> On Mon, Apr 7, 2008 at 1:30 PM, Nick Holland <nick.a.holland at gmail.com 
>>>> >
>>>> wrote:
>>>>
>>>>> Mike,
>>>>>
>>>>> As requested, here is the code involved:
>>>>>
>>>>> routes.rb
>>>>> --------------------------
>>>>>
>>>>> ActionController::Routing::Routes.draw do |map|
>>>>> map.resource :home
>>>>> end
>>>>>
>>>>> event_publisher.rb
>>>>> --------------------------
>>>>>
>>>>> class EventPublisher < Facebooker::Rails::Publisher
>>>>> include ActionController::UrlWriter
>>>>>
>>>>> def profile_update(uid, session)
>>>>> user = Facebooker::User.new(uid, session)
>>>>> send_as :profile
>>>>> from user
>>>>> recipients user
>>>>>
>>>>> Facebooker::Session.current = session
>>>>>
>>>>> profile render(:partial => 'profile/profile' )
>>>>> end
>>>>> end
>>>>>
>>>>> _profile.fbml.erb
>>>>> ----------------------
>>>>>
>>>>> <%= render(:partial => 'profile/style' ) %>
>>>>>
>>>>> <div id="content" class="wide">
>>>>> <%= link_to 'test', home_path %>
>>>>> </div>
>>>>>
>>>>> ----------------------
>>>>>
>>>>> Pretty basic stuff -- I hope I'm doing something thats obvious  
>>>>> so I
>>>>> can get this fixed up ;) I am using resource routes throughout the
>>>>> rest of my code without issue. It is just partials under Publisher
>>>>> that fail.
>>>>>
>>>>> Thanks,
>>>>> Nick
>>>>>
>>>>> On Mon, Apr 7, 2008 at 7:50 AM, Mike Mangino
>> <mmangino at elevatedrails.com>
>>>>>
>>>> wrote:
>>>>
>>>>>
>>>>>> Can you show the exact code you are using and also let us know  
>>>>>> what
>>>>>>
>>>>>
>>>> version
>>>>
>>>>>
>>>>>> of Rails you are using?
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Apr 5, 2008, at 4:47 PM, Nick Holland wrote:
>>>>>>
>>>>>>
>>>>>>> Hello!
>>>>>>>
>>>>>>> Thanks for the response Mike and Nicholaus. I apologize for the
>> delay
>>>>>>> in replying, but I have been deep in development mode and
>> deploying my
>>>>>>> Facebook Application.
>>>>>>>
>>>>>>> I was running an older version of Facebooker, so I thought I'd  
>>>>>>> try
>> and
>>>>>>> upgrade my application today to the newest version. Happy to see
>> that
>>>>>>> a number of bugs have been fixed that I had money patches for,  
>>>>>>> but
>> I
>>>>>>> still am experiencing some issues using *_path() style paths in
>>>>>>> partials under the Publisher framework.
>>>>>>>
>>>>>>> There has been a change in the errors I receive, though. I do  
>>>>>>> not
>>>>>>> receive the previous error "undefined method  
>>>>>>> `default_url_options'
>> for
>>>>>>> ActionView::Base:Class", anymore. There is a path returned,  
>>>>>>> but it
>> is
>>>>>>> relative. I attempted modifying my code to use ":only_path =>
>> false"
>>>>>>> in my _path method call, to see if I'd receive a full, absolute
>> URL
>>>>>>> with my application path. Unfortunately, I receive an exception
>> which
>>>>>>> was caught by my event processor:
>>>>>>>
>>>>>>> "Missing host to link to! Please provide :host parameter or set
>>>>>>> default_url_options[:host]"
>>>>>>>
>>>>>>> I took a look in the publisher code and see that
>> default_url_options
>>>>>>> method is indeed defined and looks right. Just for laughs, I
>> copied
>>>>>>> this decleration into my own publisher class, to see if it would
>> work.
>>>>>>> I still receive the same error.
>>>>>>>
>>>>>>> It looks like we are getting closer to solving the problem. I  
>>>>>>> hope
>> one
>>>>>>> of you with some more intimaacy with this framework could assist
>> me,
>>>>>>> as currently I have to build all my publisher URLs in my  
>>>>>>> partials
>>>>>>> manually as strings (yuck!).
>>>>>>>
>>>>>>> Thanks for your assistance, I greatly appreciate it!
>>>>>>>
>>>>>>> - Nick
>>>>>>>
>>>>>>> On Thu, Apr 3, 2008 at 1:28 PM, Nicholaus Ames
>>>>>>> <nicholaus.l.ames at gmail.com> wrote:
>>>>>>>
>>>>>>>
>>>>>>>> Nick,
>>>>>>>> Did you ever get the url_helpers in there?
>>>>>>>>
>>>>>>>> Nick
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Sun, Mar 30, 2008 at 10:26 PM, Nick Holland
>>>>>>>>
>>>>>>>
>>>>>> <nick.a.holland at gmail.com> wrote:
>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> Hello,
>>>>>>>>>
>>>>>>>>> I am running into issues using *_path() and *_url() helpers
>> the
>>>>>>>>> Facebooker Publisher framework. I encounter the following
>> error
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>> when
>>>>
>>>>>
>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>>> using these helpers while *inside of a partial*:
>>>>>>>>>
>>>>>>>>> undefined method `default_url_options' for
>> ActionView::Base:Class
>>>>>>>>>
>>>>>>>>> I've seen a few other people speak about this issue, yet I
>> haven't
>>>>>>>>> seen any resolution on the mailing list yet. Here is an
>> example
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>> stub
>>>>
>>>>>
>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>>> method that I am using the partial in:
>>>>>>>>>
>>>>>>>>> def simple_notification(event_data, partial_name)
>>>>>>>>> send_as :notification
>>>>>>>>> from event_data[:user]
>>>>>>>>> recipients event_data[:target_uids]
>>>>>>>>> fbml render(:partial => "event/notification/" + partial_name,
>>>>>>>>> :event => event_data[:event])
>>>>>>>>> end
>>>>>>>>>
>>>>>>>>> Note, _path() and _url() helpers work flawlessly from the
>>>>>>>>> simple_notification method's context, but fails miserably
>> inside
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>> the
>>>>
>>>>>
>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>>> partial. I assume this issue also exists with asset helpers.
>>>>>>>>>
>>>>>>>>> Any ideas? Am I missing something?
>>>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>> Nick Holland.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> Facebooker-talk mailing list
>>>>>>>>> Facebooker-talk at rubyforge.org
>>>>>>>>> http://rubyforge.org/mailman/listinfo/facebooker-talk
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Nicholaus Ames
>>>>>>>> 503-544-5813
>>>>>>>> ri.niculo.us
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Facebooker-talk mailing list
>>>>>>> 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
>>>>> http://rubyforge.org/mailman/listinfo/facebooker-talk
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Christopher Bailey
>>>> Cobalt Edge LLC
>>>> http://cobaltedge.com
>>>>
>>> _______________________________________________
>>> Facebooker-talk mailing list
>>> Facebooker-talk at rubyforge.org
>>> http://rubyforge.org/mailman/listinfo/facebooker-talk
>>>
>>
>> --
>> Mike Mangino
>> http://www.elevatedrails.com
>>
>>
>>
>>

--
Mike Mangino
http://www.elevatedrails.com





More information about the Facebooker-talk mailing list