small medium large xlarge

Posts by William Hertling

06 Dec 2008, 06:19
William Hertling (23 posts)
(from Developing Facebook Platform Applications with Rails > "Application has failed to start because MSVCR90.dll was not found" error message)

I’m struggling trying to get even the chapter 1 example running.

When I run “ruby script\server” on my Windows XP machine using Ruby 1.8.6 with Rails 2.1.2, I get the error message “Ruby.exe - Unable to locate component: This application has failed to start because MSVCR90.dll was not found. Re-installing the application may fix this problem”. This error appears during the “Booting WEBrick” phase. If I click OK, then the WEBrick server appears to start, but Facebook reports a “Received HTTP error code 500 while loading http://:3000/" error message.

I have previously developed Facebook applications using RFacebook and Rails, so I think my rails install is good and working. And I don’t receive the MSVCR90.dll error message when I start my old RFacebook rails application, only when starting the network_test application from the source code provided.

Any ideas?

Thanks, Will

16 Dec 2008, 04:59
William Hertling (23 posts)
(from Developing Facebook Platform Applications with Rails > URL Rewriting issue - missing app name from _path and _url)

Sorry to chime in here, but where can I find an explanation of how URL rewriting works? I’m having some problems getting it to work, and I can’t figure out where to find an explanation of it in either the Agile Development using Rails 2.0 or the Facebook Platform Development with Rails book.

I’ve been following along this book, working on my application, and I’m specifically working on my own version of the form to invite friends. In my view (invite.fbml.erb) I’ve got a line of code that looks like: <%= fb_req_choice(“Make a magic wish!”, invite_canvas_path(:from=>current_user,:canvas=>true))%>

I want invite_canvas_path to resolve as /magicwish/canvas/invite, but I’m getting a “undefined method `invite_canvas_path’ for #" error.

29 Dec 2008, 07:04
William Hertling (23 posts)
(from Developing Facebook Platform Applications with Rails > redirect error off accepting an invite request, chap 2.4, p 44)

By following the instructions to set the post_authorize_redirect_url, I’ve gotten the flow to look correct from the end-user experience. But I’m trying to track which user invited which user, and I’m having difficulty there.

The snippet of code that generates my invitation url looks like this: url="#{invitee_canvas_url(:sireid=>@current_user.facebook_id,:canvas=>true)}

The invitee method in my canvas controller never gets called though, because “Filter chain halted as [:ensure_authenticated_to_facebook] rendered_or_redirected.”

In application.rb controller, I have: ensure_authenticated_to_facebook [:except => ‘add_facebook_application’]

How do I get the invitee controller method to actually process? I want it to handle the parameter sireid, and save it to the user object.

Thanks, Will

28 Jan 2009, 18:47
William Hertling (23 posts)
(from Developing Facebook Platform Applications with Rails > Using facebook_form_for with RESTful routes)

I am trying to use facebook_form_for, but I am having a hard time figuring out what parameters to pass when I am using RESTful routes.

I need the form to have a url of the format: /wishlist/:id/wishitem/lookup, where the id is the id of the wishlist.

But what I am getting with the code shown below is “/wishitem/lookup”. Basically, I am losing the context of the wishlist.

@<% facebook_form_for(:wishitem, @wishitem, :url => url_for(:action => :lookup), :labelwidth => ‘75’, :width => ‘500’) do f %>@

What parameters do I need to pass?

Thanks, Will

02 Feb 2009, 06:39
William Hertling (23 posts)
(from Developing Facebook Platform Applications with Rails > registering templates for mini-feed items)

I have a pretty simple Publisher that just handles posting a :user_action. Below is the definition of the publisher. It doesn’t seem to work though: nothing shows up in my mini-feed. There’s no error message, just no news item. Do I need to do something to register the feed template first, or does that happen automatically?

class WishlistPublisher < Facebooker::Rails::Publisher
	helper :application

	def additem_feed_template
		one_line_story_template "{*actor*} added {*item*} to their Magic Wishlist. {*copy*}"
	def additem_feed(fb_user, wishitem)
		puts "******* WishlistPublisher.additem_feed: for user #{}"
		send_as :user_action
		from fb_user
		data 	:actor=>,
			:item=>"<a href=\"#{wishitem.url}\">#{wishitem.description}</a>",
			:copy=>"<a href=\"#{copy_existing_item_url(wishitem)}\">(Add to your wishlist</a>)"		

And here’s how I call the publisher:

pubber =
pubber.additem_feed(facebook_session.user, @wishitem)
09 Feb 2009, 19:29
William Hertling (23 posts)
(from Agile Web Development with Rails (3rd edition) > how to generate urls for nested objects correctly)

If my model contains nested objects, what’s the right way to generate urls? For example, I have a wishlists, and wishitems. A wishitem belongs to a wishlist. My URLs should be formatted like this: “appname/wishlist/:id/wishitem/:id”, where the first :id is the id of the wishlist, and the second :id is the id of the wishitem.

How do I correctly specify a url of that type, whether for use in a form, or a redirect_to or a link_to call? Do I need to create named routes? And if I do, how do I distinguish between the first id and the second id, or does that happen automagically?

Thanks, Will

11 Feb 2009, 07:29
William Hertling (23 posts)
(from Developing Facebook Platform Applications with Rails > Dealing with "No integer type has byte size 20" problems with MySQL)

I started my development of my application using SQLite3. I’m now trying to move to a production server using MySQL. Unfortunately MySQL is choking on the migrations for facebook user ids. As Mike suggest in the book, I’ve gone with a 20 byte integer:

== 20081215194758 AddSireToUser: migrating ==================================== – add_column(:users, :sire, :integer, {:limit=>20})

This is very similar to what Mike has in the book on page 53, where he defined a facebook id as: t.integer :facebook_id, :limit=>20, :null=>false

However, I get this error message when running db:migrate: rake aborted! No integer type has byte size 20

Any suggestions on how to get past this?

Thanks, Will

11 Feb 2009, 20:50
William Hertling (23 posts)
(from Developing Facebook Platform Applications with Rails > Dealing with "No integer type has byte size 20" problems with MySQL)

I got around this by patching the mysql adapter according to the blog post I found here:

Essential, the patch changes the way mysql interprets :limit like this:

def type_to_sql(type, limit = nil, precision = nil, scale = nil)
        return super unless type.to_s == 'integer'
        case limit
        when 0..3
        when 4..11
        when 12..20
13 Feb 2009, 23:57
William Hertling (23 posts)
(from Developing Facebook Platform Applications with Rails > Help with CSS)

I understand the basics of CSS, but when you put CSS, Facebooker, Rails, and Facebook together, I’m a little lost. Could anyone given me a basic overview of what I would need to do to, for example, change the layout of a form generated by facebook_form_for?

Here is an example of my form, slightly anonymized from the actual code. This form renders strangely: all the labels are right aligned, and all the inputs are centered (instead of left aligned).

I want to adjust the layout, so that the radio buttons (which currently get rendered in the middle of the page) are instead rendered next to the labels, and so that the URL text entry (second input in form) gets rendered to the right of the first radio button.

I’m not even sure how to tackle this, since so much of what gets rendered is output from these helpers.

<% facebook_form_for([@resource, @nestedresource], :url => save_item_link_path(:resource_id =>, :nestedresource_id => do |f| %>

    <%=f.radio_button :url_type, "specified", :label=>"Yes, my item has a URL"%>
    <%=f.text_field :url, :label=> "Enter the url"%>
    <%=f.radio_button :url_type, "abstract", :label=>"No, my doesn't have a URL" %>
    <%=f.radio_button :url_type, "unknown", :label=>"I don't know the URL" %>

   <%=f.buttons "Save" %>
<% end %>

Thanks so much, in advance, for any tips anyone could give me. It would be a giant help.

Thanks, Will

13 Feb 2009, 23:56
William Hertling (23 posts)
(from Developing Facebook Platform Applications with Rails > No route matches "//javascripts/facebooker.js")

Here’s how I include the facebooker javascript:

	<%= javascript_include_tag "facebooker" %>

But then I get this message:

ActionController::RoutingError (No route matches "//javascripts/facebooker.js" with {:canvas=>false, :method=>:get}):
    C:/dev/InstantRails2/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/routing/recognition_optimisation.rb:67:in `recognize_path'

Any suggestions?

Thanks, Will

19 Feb 2009, 19:37
William Hertling (23 posts)
(from Developing Facebook Platform Applications with Rails > Sortable and draggable items)

Is it possible to implement sortable and draggable items using Facebooker? For example, the Pragmatic Programmer title “Agile Development Using Rails” has several examples using the draggable_element helper, and the sortable_element helper.

Is it possible to do the same thing in Facebooker? I know that Facebook puts some limitations on the available Javascript.

Thanks, Will

01 Jul 2009, 20:50
William Hertling (23 posts)
(from Developing Facebook Platform Applications with Rails > Redirected to API feed after login)

I’m also interested in the resolution of this question. In my app, I have the user put a Bookmarklet in their browser bookmark bar. - the purpose is to allow the user to store certain web urls using my Facebook app. So in the case where the user is not logged in, I get the same error describes above. Like Mark, I don’t want to simply redirect back to a given canvas url, I want to go to the intended page. Thanks, Will

01 Jul 2009, 21:01
William Hertling (23 posts)
(from Developing Facebook Platform Applications with Rails > How to implement predictive text entry)

Is the current level of Javascript support sufficient to be able to do predictive text entry in a form? I want to be able to have my users start typing in an text input field in a form, and after they enter the first four of five characters, I’d like to pop up some matching entries based on what other users have previously submitted. Obviously then I would want to continue to refine these results as the user continues to type. I imagine there is a server side component that is looking up the partial strings in a database, getting complete strings that match from the database, and then returning those to the browser.

Has anyone implemented this, and can you share code or an outline of how to go about doing this?

Thanks, Will

02 Jul 2009, 17:46
William Hertling (23 posts)
(from Developing Facebook Platform Applications with Rails > Redirected to API feed after login)

I haven’t tried this yet, because I don’t know how to figure out what the original URL was. For example, in my case the user is trying to go to:

But they end up at: ~~~

:3000/?auth_token=7d32e62c7ad16e0... ~~~ How can I determine the original URL in the @after_facebook_login_url@ method?
10 Jul 2009, 17:46
William Hertling (23 posts)
(from Developing Facebook Platform Applications with Rails > Profiling)

I signed up for RPMlite, which is free. It couldn’t be easier to install and use (with the exception being the developer mode, see below), and so it is great from that perspective.

The good: it shows me the slowest controller actions, and for those actions, shows at the top level where the time is being spent: in template rendering versus in the controller method for action. But unlike using ruby-prof, for example, it does not seem to allow me to then drill-down to the next level - which would show me exactly which methods the time is being spent in.. Is that something I can get by signing up for the paid service? It wasn’t clear from reading their website.

In particular, I’m interested in how much time is spent calling back to Facebook and how much time is spent calling Amazon’s AAWS API, two of the things I think my applications spents a lot of time in.

Now the one thing I am having problems with is developer mode, which you access from http://localhost:3000/newrelic. When I hit that URL in my browser, I get this error message on the console:

Processing NewrelicController#index (for at 2009-07-10 10:43:08) [GET]
  Session ID: 5867cdfbabe57cc9aad0f267-707883401
  Parameters: {"action"=>"index", "controller"=>"newrelic"}
Rendering template within layouts/newrelic_default
Rendering newrelic/index

ActionView::TemplateError (undefined method `request_comes_from_facebook?' for #<ActionView::Base:0x44ef3a0>) on line #11 of vendor/plugins/newrelic_r
8:                         <%= link_to_if (params[:h] ||params[:u]), 'Timestamp' %>
9:                     </td>
10:                     <td>
11:                         <%= link_to_unless_current('Resp. Time', :h => 'y') %>
12:                     </td>
13:                     <td>
14:                         <%= link_to_unless_current('URL', :u =>'y') %>

Any ideas how to resolve this?

Thanks, Will

17 Jul 2009, 18:31
William Hertling (23 posts)
(from Developing Facebook Platform Applications with Rails > Speeding up FQL query)


I have a FQL query that looks like this:

fql_stmt = "SELECT uid, last_name, first_name, name, birthday, pic_square, is_app_user FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = #{current_user.facebook_id})"
friends = current_user.facebook_session.fql_query(fql_stmt)

It’s taking about 1200ms to run this query. Is that normal? Is anything I can do to speed things up? If it matters, my objective is to get the list of friends with birthdays in less than 6 weeks. This FQL call is about 90% of my total execution time.

Thanks, Will

27 Jul 2009, 20:31
William Hertling (23 posts)
(from Developing Facebook Platform Applications with Rails > Need a simple AJAX example)

I’m still having a hard time understanding how to do AJAX. The examples in the book are mostly about updates, but that’s adding an extra level of complexity that is making it harder for me to understand. I’d love a simple example that just gets more of something. For example, on one page of my app, I show friends with upcoming birthdays, but for usability, limit it to to show at most the six next birthdays. I’d like to have a “show more” link, which if clicked, would get the next six birthdays, and insert them into the page without refreshing.

Obviously I will need an controller action which will provide the HTML (FBML actually) of the next six birthdays. Since I will want the user to be able to hit this button several times, I’d want to pass a parameter of the next birthday to start with (initially it will be 6, and will increment by 6 each time). Let’s say that this action is available at:

What should the “show more” FBML look like?

Thanks, Will

04 Nov 2009, 20:03
William Hertling (23 posts)
(from Developing Facebook Platform Applications with Rails > Too many redirects from ensure_authenticated_to_facebook)


Within the last day or so, our app has suddenly broke. We haven’t pushed any code changes, so I’m curious if Facebook has pushed any changes that would have broken things?

The behavior I see is that when we call ensure_authenticated_to_facebook, it repeatedly redirects. In other words, when it hits ensure_authenticated_to_facebook, it always takes the create_new_facebook_session_and_redirect! path.

  def ensure_authenticated_to_facebook
    set_facebook_session || create_new_facebook_session_and_redirect!

Any ideas what could be wrong?

I’m not sure the right way to find out what version of the facebooker I have.

According to what’s in facebooker.gemspec, I have: s.version = “1.0.48” According to what’s in the changelog:

=== HEAD

  • New Features

    • Facebooker::User#publish_to for publishing to a Wall or News Stream
    • Optionally parses with Nokogiri. Just require ‘nokogiri’ in your app.

=== 1.0.13 / 2009-02-26 …

18 May 2011, 23:22
William Hertling (23 posts)
(from Agile Web Development with Rails 3.2 > File uploading example)

Can anyone get the file uploading example to work? In Rails In Depth, Action View, Uploading Files to Rails Applications (starts at p.345). I can’t seem to get it to work. I’m getting routing errors. The example given doesn’t tell us what, if any, routes need to be defined.

First it complained that index wasn’t defined. I redefined the get method on the controller to index. Then it complains that the save route isn’t defined: No route matches {:action=>”save”, :controller=>”upload”}

I tried adding this to routes.rb:

resources :upload do get :get get :save end

But still no luck. save is defined in my UploadController. What else do I need to do to get this to work?

23 posts