A.Kimura A.Kimura - 1 year ago 84
CSS Question

a href="url" image loading error

Main page code:

<img src = "assets/headbar.jpg"></img>
<a href= <%= AApage_index_url %> >AA page</a>
...


AA page code:

<img src = "assets/headbar.jpg"></img>
<a href= <%= AApage_index_url %> >AA page</a>
...


When I add
root "homepage/AApage"
to
config/routes
image is loading well in AApage.
When I add
root "homepage/mainpage"
to
config/routes
image is loading well in main page.
Then I click
AA page
and website shows AApage but image is not loading.
Why did this happen and how to fix this error?

Edit:
confg/routes
content

Rails.application.routes.draw do
root "homepage#mainpage"

resources :homepage do
collection do
get :mainpage
get :AApage
end
end
end

Answer Source

Your error comes from resources :homepage.

resources :homepage will change default route of homepage views from /app to /app/homepage.

So you can use <img src = "../assets/headbar.jpg"></img>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download