Why does my logo fail to load after logging into Rails App? - ruby

My logo loads on my RoR application locally. When I login however, it fails to load each time. If however, I redirect to the same page, it will load again. I'm not sure I understand what the problem is.
The link to my project can be found here https://github.com/dlyons8/family-and-community.

The logo cannot be loaded because your path is being changed after successfully logging in as an user. The Sessions controller will be redirect the user to /users/:user_id.
The affected src attribute in the <img> tag contains "logo.png" so the browser tries to fetch /users/logo.png which will not succeed.
You have two options:
1) Change your logo as an asset. This is commonly used pattern for resources and helps a lot later in deployment when you change the logo for example. Move logo.png to app/assets/images and in the app/views/layouts/application.html.erb use the image_tag helper:
<%= image_tag 'logo.png', alt: 'Logo' %>
In this way, you will always get the absolute path of your logo (/assets/logo.png) and don't have to worry about where is the user actually.
2) Change the path in the <img> tag to absolute path of the logo (/logo.png) and it will try to fetch the correct file.
The 2) solution would be easier, however I strongly recommend you to get in touch with the Asset Pipeline in Rails because it really helps a lot in handling static assets for your webpage.
Also, if you encounter a non-loading asset, always check the browser's console. In Google Chrome, you can reach it by simply pressing F12 and switching to Console tab, there will be a red error message about what resource could not be loaded and why. The displayed full URL is often helps in these sneaky problems.

you need to place the images under assets/images folder
<%= image_tag ("/assets/ruby.jpeg") %>
change assets compile to true default it is false in config/environments/development.rb
config.assets.compile = true

Related

Cannot Load from URL in Kendo Panel Bar tab

I need to load the content of a new tab from a URL but I cannot get this to work
I need the same kind of thing as would have been done with an IFrame before HTML 5
The website I am going to has no link to the hosting site whatsoever
I have tried a simple version first
#(Html.Kendo().PanelBar()
.Items(panelbar =>
{
panelbar.Add().Text("Test").LoadContentFrom(#"<object data='https://www.google.com' type='text/html'/>");
})
)
Has anyone been able to do this?
I am using the MVC wrappers as you can see
Paul
Firstly, you need to specify a name for your panelbar, otherwise it won't work. With regards to LoadContentFrom you should simply supply it with a url. Including this html markup makes no sense. So your code needs to look like this:
#(Html.Kendo().PanelBar()
.Name("Test")
.Items(panelbar =>
{
panelbar.Add().Text("Test").LoadContentFrom(#"https://www.google.com/");
})
)
However, this is still not going to work, because the request to google.com (or any other https site without the proper access-control-allow-origin header) will be blocked by CORS.
So this scenario may or may not work, depending on the external site you want to load from.
Furthermore, if you do not have a CORS issue and you are able to load the contents, this is still not going to work like an iframe, because you will receive only HTML, which will likely have broken images and no CSS. That's because you will be placing this html in a document, which has no access to those resources, unless they are referenced by domain name. You would have to search the entire html you receive and replace any image, css, and javascript references... and that still might not provide the same experience as an iframe.

Unable to load image after template is rendered using Router in Meteor

I'm running Meteor 0.6.6.1, using the package Router and all my images are in the public folder.
My issue is: when I'm in the URL root (http://localhost:3000), after the template is rendered, I am able to load an image, as illustrated using the console in the image below:
But when I'm in another URL (http://localhost:3000/orderProduct/frame1) using the Router to drive the right template, I can't load the same image after the template is rendered, as shown in the image below:
As we can see from the console's output, the only difference is the well known Chrome's warning about the content type.
I would like to load the images in a routed URL after the template is rendered. Someone can help me, please?
Thanks in advance.
You use relative URLs for images, the ones that does not start with /. In this case, browser search for the image RELATIVE to the current document path. So in the second case, it search in the orderProduct folder, which does not exist - and hence the error. See what's the image URL the browser tries to fetch, it's different in the two examples.
To solve your problem use absolute path, the one starting with /:
$('body').append('<img src="/imageName.png">');
In this case, the browser will look for the photo in the given path on the current server, and it will find it regardless on what's the current page address.

Facebook linter reports og:image is too small, when it is larger than the image it choose instead

Problem:
linter reports that specified og:image is too small. Image is 628x464.
linter instead picks a random image from the page which is 380x214, smaller than
the og:image!
What the linter shows me:
http://developers.facebook.com/tools/debug/og/object?q=futuremark.com
Background:
We have been happily using 130x110 og:images without problems for the last 9 months. I noticed in the last couple of weeks that pages were no longer sharing the correct image. Using the linter it seems that Facebook recently decided og:images should be at least 200x200. So I have been replacing our og:images with larger examples but the linter still says they are too small.
Any ideas how I can fix this, or is it a Facebook problem? Thanks.
Now I guess that Facebook does not find tags for height and width and considers them null. In my case, next tags fixed this issue:
<meta property="og:image:type" content="image/jpeg" />
<meta property="og:image:width" content="1280" />
<meta property="og:image:height" content="855" />
Did you change how big the image file at http://www.futuremark.com/images/facebook/futuremark-logo.png is without changing the URL specified in the og:image meta tag?
The image itself will be cached if the URL didn't change, so you need to change the URL (or add a cash-busting parameter like ?v=1 to the end)
I ran into this same issue, for me the problem was with the URL defined in the og:image not matching the URL being checked
for example my og:image tag had
<meta property="og:image" content="http://www.soundfuse.co.uk/public/images/logo_300px.png"/>
And the URL I was actually checking against was
http://soundfuse.co.uk
Notice the missing www. on the TLD? This caused a 301 redirect to occur from soundfuse.co.uk to www.soundfuse.co.uk, but once I matched both primary URL's up it worked as expected.
This issue is also triggered if you're enforcing no trailing slashes with .htaccess [301]. Facebook infers this slash if no og:url is present.
There is a useful workaround for this issue. If you use a URL shortener to create a new URL, the image seems to load without error.
For example, paste your Youtube URL into bitly.com's URL shortener, then paste the shortened URL into Facebook. The thumbnail image will then be displayed as intended.
Please see the link below for facebook open graph image cache problem:
https://developers.facebook.com/docs/sharing/webmasters/?locale=en_US#images
It says that:
URL for the image. To update an image after it's been published, use a
new URL for the new image. Images are cached based on the URL and
won't be updated unless the URL changes.
So, to sum up, if you already have an open graph image that is indexed by facebook and if you would like update it, you should change the URL.

Where does FireFox-10 hide the URL Favicon relationship?

We use CentOS-6, a RedHat EL6 distro rebuild, and this ships with FireFox-10.0.12 ESR. We recently changed the favicon.ico image on several internal servers. Actually we just provided the corporate favicon to those sites that had none.
Now, the difficulty is this. When a FF user who visited a given url before the favicon was provided now visits that url following the update then the new favicon is not displayed in either their URL address bar or in the tab for that page. Instead they see that dashed box outline indicating that no favicon is present.
However, when a FF user who had never previously visited that same url does so then that FF instance does display the new favicon in both the address bar and tab on that FF browser.
I have looked into this briefly and frankly was astounded at how common this problem appears to be and the absolute lack of any sensible response to the issue even on Mozilla's own support forums. I have tried hacking and picking at the places.sqlite store but even deleting the entire places.sqlite file or emptying the favicon tables and restarting firefox does not solve the problem of displaying a changed favicon the tab and url icon display. All that does is hammer the user's bookmarks.
Now I can, and have, resorted to the trick of adding <link rel="icon" href="favicon.ico"> in the <head></head> block of those urls that use static pages but some are generated dynamically by third-party applications. These urls do not offer a convenient method to make this modification to their output.
Where does FireFox-10 cache the favicon for a newly visited url and how does one remove that reference from the user's profile?
A browser does not necessarily request a fresh copy of the /favicon.ico (or an icon specified by a meta tag) on each visit. Once it has a favicon (or thinks there isn't one), it is often some time before it will request an update (this depends on the particular browser). I have had some success with unbookmarking a site and clearing the browser cache.

Wrong image on like button

To start with I am new to facebook "like" button integration
I have a facebook like button on my webside (http://www.mini-signs.dk/index.html), but the image showing when like button is pressed is incorrect. I've tried to use meta tag
in between and on the page but it seems like it choosing a images name Galleri-Andet-Normal.jpg in the same folder.
I've tried to delete the image and overwrite it, and now something different is showing in the facebook timeline when liking the side, but the image in the like button dialog is still wrong. If i put the content value in a browser the correct image is showing
I've tried a lot of things og googled to solve it my self
Please help me out.
Only option you have is that you change your meta tags and WAIT. Once your page is crawled again, you will get new images :)
Try here and look where is the problem,
http://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fwww.mini-signs.dk%2Findex.html
All the images referenced by og:image should be at least 200px in both
dimensions. Please check all the images with tag og:image in the given
url and ensure that it meets the recommended specification.
fb:admins and fb:app_id tags are missing.

Resources