wicked_pdf does not include styles - ruby-on-rails

I used
<%= wicked_pdf_stylesheet_link_tag "pdf" %>
it shows the following output in the html
<link href="/stylesheets/pdf.css?1302860585" media="screen" rel="stylesheet" type="text/css">
<link href="file:///home/likewise-open/NEXTBRIDGE/nazar.hussain/osd/development/atlantis/public/stylesheets/pdf" media="screen" rel="stylesheet" type="text/css">
But when create the pdf it do not have any style. If i copy all css from the file to the header of the page, it includes all styles. What is the issue and how to solve it.

I personally haven't had any trouble with this method, but I've seen others that have.
I just pushed some updates to the main project that should resolve this issue for you.
wicked_pdf_stylesheet_link_tag now will inline any css files passed in directly into the markup.
I also updated the Github issue you created.

Related

CSS link in html

I'm linking to a css file in html but it doesn't seem to apply.
/style.css" rel="stylesheet">
html is complaining on the second < as if it wouldn't be closed and is marked red. Anyone who know's anything about this issue?
The CSS link in an HTML page you have to do it like this
<link rel="stylesheet" href="style.css" /> provided that the HTML and CSS file are in the same folder

MVC head components

I'm quite new to MVC. In my website I use a layout for all the views and I was wondering how could I add links to certain .css files.
What I mean is that if I add them in the _layout.cshtml, all HTML files will have that link although some of them don't need it, which could lead to performance issues??
How could I do this? Thanks!
Layout page works like a master page. You can define a section in the partial view and then render it in the layout page:
Define a section named (Styles) in the view that needs (yourView_style.css) file to be rendered:
#section Styles {
<link href="#Url.Content("~/Styles/yourView_style.css")" rel="stylesheet" type="text/css" />
}
In (_layout.cshtml) render the (Styles) section:
<head>
<link href="#Url.Content("~/Styles/main.css")" rel="stylesheet" type="text/css" />
#RenderSection("Styles", false)
</head>

Devise Views Not Getting Styled in Rails

I have been working on an application for the Rhode Island State Police. I decided to use the devise gem to handle user auth. After running rails generate devise user. I went to the /sign_up page, and found that it was all there, but just as html. For an example of my problem check out my app
http://systemsgroup2.herokuapp.com/
http://systemsgroup2.herokuapp.com/users/sign_in
Thanks for the help.
Your stylesheets are referenced relative to the current path.
In your layouts (or where ever you include your stylesheets) change the paths from
<link rel="stylesheet" href="assets/skel.css" />
<link rel="stylesheet" href="assets/style.css" />
<link rel="stylesheet" href="assets/style-wide.css" />
to
<link rel="stylesheet" href="/assets/skel.css" />
<link rel="stylesheet" href="/assets/style.css" />
<link rel="stylesheet" href="/assets/style-wide.css" />
Your stylesheets are not loading for the /user directory because instead of looking for assets/stylesheets it is looking for assets/users/stylesheets. To fix this you can use Rails stylesheet helper instead of manually linking to the stylesheets:
<%= stylesheet_link_tag "application" %>

Can't get CSS loaded in Master page

So I am trying to simply load a .css file from within the master page.
The master page Admin.Master and the css file AdminView.css are both in the /views/shared folder. I am sticking the following link tag in the section of my Master page.
I have tried both:
<link href="<%: ResolveUrl("AdminView.css")%>" rel="stylesheet" type="text/css"/>
and
<link href="AdminView.css" rel="stylesheet" type="text/css"/>
As well as every other combination (~/views/shared/adminview.css OR /adminview.css....etc)
and when viewing in Firebug what it loads, it always returns "Resource not found".
NOTE: I have double checked the name and spelling.
Its these trival stuff that shouldn't be this difficult.
You can't access resources in the Views folder directly from the web. You should put your content in the Content folder (or Content/Styles) and reference it from there. The Views folder is for the framework to use to find your Views, it isn't visible from the web.
<link href="<%: Url.Content( "~/content/styles/adminview.css" ) %>" ... />
<link href="/views/shared/AdminView.css" rel="stylesheet" type="text/css"/>

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" /> ?

Resources