Guest User

Untitled

a guest
Nov 24th, 2017
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. class Api::Mobile::HomeController < Api::Mobile::ApplicationController
  2. include ActionView::Helpers::AssetUrlHelper
  3.  
  4. def index
  5. @items = [Api::Mobile::HomePageItem.new(
  6. type: 'image',
  7. image: image_url("api/mobile/home/tutor-with-student.jpg"))]
  8. end
  9. end
  10.  
  11. app/assets/images/api/mobile/home/tutor-with-student.jpg
  12.  
  13. http://myhost.com/images/api/mobile/home/tutor-with-student.jpg
  14.  
  15. http://myhost.com/assets/api/mobile/home/tutor-with-student.jpg
  16.  
  17. ActionController::Base.helpers.asset_url("api/mobile/home/tutor-with-student.jpg", type: :image)
  18.  
  19. config.action_controller.asset_host='myhost.com'
  20.  
  21. def logo_url
  22. host_url = request.original_url.split(request.path).first
  23. asset_path = ActionController::Base.helpers.asset_url('logo.png')
  24. host_url + asset_path
  25. end
  26. # will return
  27. => "http://localhost:3000/assets/logo-40e3bf1e10f0c00393ac94f96ea127986955c166eb839266eb2ad6e63b42754c.png"`
Add Comment
Please, Sign In to add comment