Tiago Scolari

bits for fun

Mobylette: Mobile Requests Handling (GEM)

2011-09-03 Code

In the last few days have been working on this gem. It’s named Mobylette and it works by identifying mobile requests in your app, and handling them with a new .mobile format.

Once you have it installed on your application, adding respond_to_mobile_requests to your controller will enable it to deal with mobile requests. It will automatically look for a .mobile.erb (.haml, or whatever) when a request comes from a mobile device. Also you can call the mobile type from a respond_to block:

Continue reading

Asynchronous UISearchBar / UISearchDisplayController With Autocomplete

2011-08-19 Code

This is my second week working with objective-c and iphone. The task is to make a search with autocomplete. Both search and autocomplete should get results from a remote webservice. I was searching google about how to populate a UISearchDisplayController with remote data, asynchronously of course, when I found a great guide here.

I already had a working datasource for autocomplete:

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
    [_autocompleteDataSource searchFor:searchString];
    return NO;
}

The trick was to reload the tableview data in my datasource ([tableView reloadData]), when it finishes loading.

Continue reading

Uploadify on Rails, without rack middleware (using devise)

2011-03-31 Code

You can avoid the middleware hack when using flash in rails with logged in users.

As you should know, the browser doesn’t share the session with flash. Before using devise, I was using a rack middleware to hack into user session.

But there is a much cleaner way if you use devise, you can use the built in feature :authentication_token.

More details on how are here.

Newer posts