CSS link to erb


#1

hello Im trying to link a CSS file to a .erb file ive tried putting both

link rel=“stylesheet” type=“text/css” href=“CSS.css”

and

<%= stylesheet_link_tag “CSS.css” %>

but neither work could someone tell me how.

thanks


#2

Where is the CSS file located? Do you have a link to the workspace?


#3

wiki/wiki.rb

wiki/css.css

wiki/views/home.erb

are where the files are located


#4

So I imagine the URL for the files is something like workspace-username.c9users.io/wiki/css.css? In that case, your path should be /wiki/css.css The slash at the beginning says that it is the start of the path, and then the rest is the folder you mentioned. What you are doing right now is simply causing the path where you look for files to be workspace-username.c9users.iocss.css where the lack of a slash simply appends it to the end. This also means if you went on /randompage it would look in /randompagecss.css. This is one of the many relative shortcuts. Another is // which means “this is the beginning of the url”, so you could do //google.com and that would resolve to http://google.com/.


#5

link rel=“stylesheet” type=“text/css” href="/wiki/css.css"

so this should be the right code for the CSS to apply to the erb file right??


#6

Yes, hopefully. If not, can you link me to the workspace or post any errors there are?


#7

https://ide.c9.io/demianvilchis/wad-project

the css just doesnt apply currently only trying on the home.erb view


#8

OK, looking at your project, can you move the CSS file into the views folder? I’ll then try to see if I can access it


#9

I have gone ahead and done it