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.

On Oct 14, 2011, at 3:13 PM, Richard L. wrote:

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.

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

On 14 October 2011 20:13, Richard L. [email protected] wrote:

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

any help will be appreciated, TIA.


You received this message because you are subscribed to the Google G. “Ruby
on Rails: Talk” group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


gplus.to/clanlaw

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