Gaurav
Gaurav

Reputation: 535

Routing error for image assets folder

I have specified image source in my view as <img src="assets/grid2Whitepressed.png" />. The file name is index.html.erb file and is part of billings controller. I am getting routing error for this

Started GET "/billings/assets/grid2Whitepressed.png" for 127.0.0.1 at 2013-09-05
 17:33:36 +0530

ActionController::RoutingError (No route matches [GET] "/billings/assets/grid2Wh
itepressed.png"):

I am new to rails so not sure if this needs to explicitly defined in routes file. I checked many posts but nowhere its mentioned that we have to define route for assets too. I checked the application.rb, development.rb file settings and everything is as mentioned on ROR site. Please advise. Thanks.

Upvotes: 2

Views: 752

Answers (2)

SSR
SSR

Reputation: 6438

<img src="/assets/yourimage.png"></img>

always give parent directory name for your path.

Upvotes: 1

Miotsu
Miotsu

Reputation: 1776

Apparently the path your route is starting from is /billing. Try this:

 <img src="../assets/grid2Whitepressed.png" />

Upvotes: 4

Related Questions