Problem with stylesheet_link_tag - ruby-on-rails

I have add stylesheet link tag to my application. I'm sure its worked. because in another place is working. but if I run at my computer it did not working. I mean my application cant load css
when I seen at view source the result is :
<script src="http://localhost:3000//javascripts/application.js?1258048544" type="text/javascript"></script>
<link href="http://localhost:3000//stylesheets/jquery.autocomplete.css?1258048544" media="screen" rel="stylesheet" type="text/css" />
I'm sure it shouldnt appear double slash // after domain or localhost:3000. weird why in other computer it was worked.
Have you any suggestion for this case? how to change double slash with single?
btw I use ubuntu.

The Rails helpers should not render an absolute url, it should simply be a relative path.
<link href="/stylesheets/jquery.autocomplete.css?1250281505" media="screen" rel="stylesheet" type="text/css" />
Make sure you are using the stylesheet_link_tag properly - do not use a leading slash or the trailing .css when specifying the stylesheet name. Same for javascript_include_tag.
<%= stylesheet_link_tag "jquery.autocomplete" %>

Maybe this helps:
Relative paths from root-stucture: "/your/path/to/file.ext"
Relative paths from the current file "your/path/to/file.ext"

Try these helper methods:
<%= stylesheet_link_merged 'jquery.autocomplete.css' %>
<%= javascript_include_tag 'application.js'%>
*Works with http://synthesis.sbecker.net/pages/asset_packager

I had a similar problem and just discovered the issue–it may or may not work for you.
My app uses the Facebooker gem to integrate with Facebook Connect. In my facebooker.yml file, if I had a trailing slash in my callback_url setting, I would get the same behavior as you described. Removing the trailing slash fixed the issue.

Related

Haml: How to include google font

%link{:href => "https://fonts.googleapis.com/css?family=Lato:400,700" :rel => "stylesheet"}
gives me error. What should I use?
Edit sorry I wasn't specific. How do I properly include fonts using haml?
Well first of all I would generally include that script in the Application Layout. When you generate a new application that is generally written in ERB which would make it quite easy to update and you would just put <link rel="stylesheet" type="text/css" "https://fonts.googleapis.com/css?family=Lato:400,700"> up at the top of the page between the <head></head> portion.
Otherwise if you are using HAML in that part of the app as well you would use %link{href="https://fonts.googleapis.com/css?family=Lato:400,700" rel="stylesheet" type="text/css"}
Now then you just have to update the CSS to use that font in the portion of the application you wish to apply it.

Weird asset url without 'http' in Rails 3.1

I'm using Rails 3.1.1, Ruby 1.9.3, asset_host='assets.foo.com'
This
<%= stylesheet_link_tag 'home' %>
<%= javascript_include_tag 'home' %>
produces
<link href="http://assets.foo.com/assets/home-f803345a3514568545f88946a69d6bab.css" media="screen" rel="stylesheet" type="text/css" />
<script src="//assets.foo.com/assets/home-da846573d17e8a062b5a8d6c122abc97.js" type="text/javascript"></script>
I can't figure out why the script's src is malformed.
I see similar URLs without the protocol schema in CSS file, as the result of the image-url() Sass helper.
Where should I look to resolve this?
It's not malformed. Most modern browsers these days will automatically put in the protocol you're using when it sees the //. It's called relative protocol resolution.
See this answer as well as RFC 3986 Section 5.2

Can't get CSS to load

I can't seem to get a css file to apply its styling to a form. It is quite frustrating now because as far as I know it should work!
In my head I have
<link href="/stylesheets/formtastic.css?1290524609" media="screen" rel="stylesheet" type="text/css" />
and in the body I have:
<form action="/agents" class="formtastic agent" id="new_agent" method="post">
The formtastic.css file should apply styling to the form. It's contents are viewable here:
formtastic.css
Any suggestions or fixes?
The problem was that the following code was not inserted in the form:
<% f.inputs do %>
This creates the html and now the css works.
i.e. the html missing was
dont you need to turn that number into a querysting var?
<link href="/stylesheets/formtastic.css?math=1290524609" media="screen" rel="stylesheet" type="text/css" />
Are you using this with Rails? If so, you could simply put this in your header:
<%= formtastic_stylesheet_link_tag %>
Also, have you run both bundle install and rails generate formtastic:install (for Rails 3, use ./script/generate formtastic for Rails 2)?
Are you sure the path is correct? if you check source with firebug check the link tag and see if its contents are a 404 error. It may be an issue with your root-relative path.
This is only a guess as I can't see how your site is structured.
Are you sure you have to begin with a forward slash ? (/)
Cause it's mean it's at the root of your domain.
Tried <link href="stylesheets/formtastic.css?1290524609" media="screen" rel="stylesheet" type="text/css" /> ?

Symfony: question about paths

in the cover page (login, register...) of my app i have this line:
<link rel="stylesheet" type="text/css" href="/css/formularios.css">
When i deploy my app, the that css rule is not loaded because, as i can
see in Firebug, it's looking for that rules in
www.tirengarfio.com/css/formularios.css instead of
www.tiregarfio.com/rs2/web/css/formularios.css.
What should i do?
Javi
You should use the view.yml config file and the include_stylesheets() helper. However, if you'd like to create the link tags by hand, use the public_path() helper to get the correct path.

Asp.net MVC Routing Problem

how many methods for adding style sheets in a page using Asp.net MVC
Wherever you're specifying the CSS for your details page instead of a relative path e.g.
<link href="../../Content/CSS/details.css" rel="stylesheet" type="text/css" />
try using the content helper and specifying a virtual path instead
<link href="<%= Url.Content("~/Content/CSS/details.css") %>" rel="stylesheet" type="text/css" />
It seems that the site is having trouble loading getting to the CSS file based on a relative link.
Use absolute links to css instead of relative (eg /Content/site.css" instead of "../Content/site.css"). Also you may use Html.Stylesheet("~/Content/site.css") extension (in MvcContrib library) to specify a stylesheet.
Is the problem not getting the right CSS? If so, then I would check your Details.aspx file and make sure the link to the CSS is the right path. Most likely, your Details.aspx file got moved into a new subdirectory or into another directory, thus making the relative paths between the aspx file and the CSS file different.
I would check the page source from the browser and look to see what the path to the CSS file is. The way I would solve the problem would be to modify the aspx file to use a fully-qualified path to the css file. Make sure that works. Then try changing the full path to use relative path.
I had the same issue when working through an example in an MVC book, it mentioned something about the '~' character only working because the <head> tag has the runat="server" attribute on it. So, I tried adding the runat attribute to the link tag itself, as seen below, and it worked:
<link runat="server" href="~/Content/styles.css" rel="stylesheet" type="text/css" />

Resources