DEV Community

Cover image for Your first Progressive Web App on Rails

Your first Progressive Web App on Rails

Ross Kaffenberger on January 02, 2017

Discussion of Progressive Web Apps (PWA) is catching fire in the JavaScript community, but amongst Rails developers... not so much. Progressive We...
Collapse
 
andy profile image
Andy Zhao (he/him) • Edited

Hey Ross, awesome gem. Was trying to play around with it and currently stuck on adding an icon to manifest.json.erb. What's the best way of adding in the src of the image? I tried using <%= asset_path %> but it doesn't quite work, at least not in development. Currently trying to "Add to homescreen" in development via DevTools -> Application -> Manifest.

Here's manifest.json.erb:

{
  "name": "blahblah",
  "short_name": "blahblahblah",
  "icons": [
    {
      "src": "",
      "sizes": "192x192",
      "type": "image/png"
    }
  ],
  "start_url": "/"
}

Again, not sure what to fill in for "src".

Collapse
 
rossta profile image
Ross Kaffenberger

Does image_path work? Check out how I'm using it in my sample app here.

Collapse
 
andy profile image
Andy Zhao (he/him)

Awesome! Thanks for the quick reply. Working so far :)

Collapse
 
ben profile image
Ben Halpern

Great looking gem, Ross. Good chance this makes it into the dev.to codebase πŸ˜‰

Collapse
 
rossta profile image
Ross Kaffenberger

Thanks, Ben. Let me know if you have any feedback when you get around to trying it out!

Collapse
 
delblues profile image
delblues

Hi Ross, very good article. I have this rails (v4.2) app with webpack working and delayed jobs running on background, and I would to know if it is possible to use this gem together with those?
tks

Collapse
 
rossta profile image
Ross Kaffenberger

Hey there. If you're using Webpack instead of the typical Rails asset pipeline, you probably just want to use Webpack to transpile and bundle your Service Worker scripts. This gem is mostly useful for folks who use Sprockets to bundle assets in their Rails apps.

The use and methodology for delayed jobs in your app is completely orthogonal to your approach to front-end assets; there'd be no conflict and/or benefit for background processing in whether you use this gem or not.