how to link to the folder in public folder

Hi guys,

I'm trying to make a folder in the public and I wanna link to the folder. I can't figure out how to do it. also how does it know when we do like <%= stylesheet_link_tag >, it will point to the stylesheet folder inside the public folder?

any help will be appreciated, TIA.

Hi guys,

I'm trying to make a folder in the public and I wanna link to the folder. I can't figure out how to do it.

I presume you mean a file in a folder under public, to link to public/myfolder/myfile.html <%= link_to "my file link" "myfolder/myfile.html" %> The web server will try and satisfy any link from the public folder first and only if it fails does it pass it on to Rails routes.

also how does it know when we do like <%= stylesheet_link_tag >, it will point to the stylesheet folder inside the public folder?

What do you mean how does it know? It is just coded to assume that is where the scripts are so it generates the html accordingly.

Colin

If you think about the public folder as the Apache root folder on a static Web server, all paths will make sense. If you're using the Rails link helper (and you don't have any conflicting routes) then it's as simple as this:

#folder structure /public   /foo     /bar       baz.html

#erb <%= link_to 'Baz', '/foo/bar/baz.html' %>

Walter

also how does it know when we do like <%= stylesheet_link_tag >, it will point to the stylesheet folder inside the public folder?

What do you mean how does it know? It is just coded to assume that is where the scripts are so it generates the html accordingly.

I don't know about 3.1, but in 3.0... look at the source for any of the asset tag helpers (ie. image_tag). That will point you to image_path which will point you to asset_path (I think) which will point you to compute_public_path. Or close to that. Anyway, that's the rabbit hole...

-philip