RailsCasts Pro episodes are now free!

Learn more or hide this

Chris Beck's Profile

GitHub User: ccmcbeck

Site: https://www.linkedin.com/in/ccmcbeck

Comments by Chris Beck

Avatar

You can just manually send the Airbrake using Airbrake.notify_or_ignore(...)

Avatar

Depends on what your are trying to do in your controller tests, but here is what I did

ruby
  before do
    controller.stub(:authorize)
  end
Avatar

If, like me, you also use Ryan's awesome nested_form gem, then you will be very interested in Issue #145 where the compatibilities with Turbolinks are getting resolved

Avatar

Erich, that looks pretty nice. Perhaps your pattern is a good way to DRY up code between two PushState frameworks (Turbolinks on Desktop / jQuery Mobile on Mobile)

Avatar

While I was thinking about it, I migrated to Turbolinks. Since I use bootstrap, I needed the https://github.com/kossnocorp/jquery.turbolinks gem to deal with the fact that bootstrap binds events to the body tag (this will be fixed in future releases to use the html tag).

Also, I use Turbolinks for my forms (like search) that use GET

javascript
  $('form[method=get]:not([data-remote])').on 'submit', (event) ->
    event.preventDefault()
    Turbolinks.visit @.action + '?' + $(@).serialize()
Avatar

It was easy (1-2 days) for me to migrate my Rails 3.2 desktop app to use PJAX via the rack-pjax gem. I picked that gem because you specify the container. I chose to just PJAX the content between my header and footer tags.

However, I have a feeling that most of the performance win comes from not reprocessing the head tag so I would expect that just fragmenting the entire body is good enuff. When I get the time, I'll migrate from PJAX to Turbolinks.

Has anyone had any experience integrating either PJAX or Turbolinks with jQuery Mobile. JQM does has it's own pushState manager and converts all links into AJAX requests. It also does DOM caching of those pages so there are several issues to consider.

Avatar

They now work out of the box with bootstrap and simple-form if you use the simple-form plugin which supports bootstrap wrappers

gem 'simple_form', '2.0.4'
gem 'client_side_validations', '3.2.1'
gem 'client_side_validations-simple_form', '2.0.1'

The gems must go in this order

Avatar

Really a great technique. Rather than using a querystring param, I choose to use the URL extension. It just felt better than a querystring since Rails already responds to that to determine the correct MIME format:

ruby
def mobile_device?
  session.has_key?(:mobile) ? session[:mobile] : request.user_agent =~ /Mobile|webOS/
end
helper_method :mobile_device?

def prepare_for_mobile
  if request.format == 'text/html'
    case File.extname(URI.parse(request.fullpath).path)
    when '.html'
      session[:mobile] = false
    when '.mobile'
      session[:mobile] = true
    end
    request.format = :mobile if mobile_device?
  end
end