Encoding::InvalidByteSequenceError in Home#index "\xA9" on UTF-8 - ruby-on-rails

I'm new to Ruby on Rails, and have been battling with this issue for a while now.
I have pulled a website from git, and made sure all the dependencies are installed, however, when I run the site, I get the error:
ActionView::Template::Error ("\xA9" on UTF-8)
because of the line linking images using the code image_path("bground2.jpg").
When I remove the image_path("bground2.jpg"), the error is resolved.
I however need image_path("bground2.jpg") and can't do without it.
I have tried the solutions here, but it seems not to work
This is a section of the index.html.erb file, but the error is recurring over all places containing the image_path and image_url:
<%= provide(:title, 'Home') %>
<section id="slider" class="">
<div class="img-responsive" style="background-image: url(<%= image_path("bground2.jpg") %>); background-position: 50% 0;height: 500px;">
<div class="container clearfix">
<!-- <div class="slider-caption slider-caption-center">
<!-- <div class="banner heading-block title-center nobottomborder">
<h1><%= "#{t('.reach_home')}" %></h1>
</div> -->

So, I solved this by reinstalling the Ruby application.
Don't know what had caused it, but I just reinstalled the application and everything works fine.
Thanks all for the help.

I had this very same issue. I identified it to a file I had in my application, actually it was taking place in minified javascript file I had in my Rails app. I open the file in text editor, added a new line and, set the encoding as UTF-8 and saved it, and the problem disappeared.

Related

ScrollSpy working on localhost, not on server

I'm developing an ASP MVC application with ScrollSpy on one of my pages. I'm having a strange problem where it's working correctly when I run my site from localhost, but when I publish the application to a server, ScrollSpy isn't adding the active class to the <li> items.
This is the script on my page which initializes ScrollSpy.
#section scripts
{
<script>
$(document).ready(function () {
$('body').attr("data-target", "#side-nav");
$('body').attr("data-spy", "scroll");
});
</script>
}
Here's how my ScrollSpy navigation is defined.
<div id="side-nav" class="pull-left">
<ul class="affix nav nav-list nav-pills nav-stacked">
<li>First Section</li>
<li>Second Section</li>
<li>Third Section</li>
</ul>
</div>
Each section has an anchor tag defined like this
<a class="anchor" id="first-section"></a>
I verified that jquery.js and bootstrap.js are referenced correctly on the server by going to View Page Source and clicking on the link to view the .js file. I tried replacing the .min versions of the files with the same .js file that's being used on localhost, but that doesn't work.
I apologize in advance for this being a difficult to recreate problem. Please tell me if I should post any additional data to make it easier to troubleshoot.

Referencing images in a Rails app (Heroku deployment)

I'm currently having a slight problem referencing images in a Rails app which is then deployed to Heroku.
I have an image in the following path relative to the app:
app/assets/images/some-image.png
And I have referenced it in the HTML correctly (as far as I am aware):
<div id="main-nav" class="collapse navbar-collapse">
<img src="/assets/some-image.png" height="67"/><!-- **IMAGE SOURCE LINK** -->
<ul class="nav navbar-nav" id="mainNav">
<li class="active">Home</li>
<li>APR</li>
<li>Initiatives</li>
</ul>
</div>
Yet, this is what is displayed:
Does anyone have any ideas why this is happening?
You should use image_tag:
<%= image_tag "some-image.png", height: "67" %>
When you deploy to heroku, your assets will get compiled with a unique digest so you can't hard-code the reference to /assets/some-image.png. Check out "Rails Asset Pipeline on Heroku Cedar".
You will need to use some helper functions so the image path is correctly resolved, like image_path('my_image.png'). See "ActionView::Helpers::AssetTagHelper" or "Asset Tag Helpers".

Images on Rails not showing up on my browser

I am trying to include an image in my web application but it is not showing up properly on my browser(localhost:3000). Have I set it up wrongly?
This is my view code:
<div class="row">
<div class="col-sm-4">
<img src="‪assets/img/Lab Potion.png" alt="#" class="img-responsive">
<h2>random text</h2>
<p>random text</p>
</div>
</div>
I downloaded an image and saved it under:
-Desktop
-rails_projects
-project_name
-app
-assets
-images
When I check in the images folder there is a file named Lab Potion.png and a bunch of random numbers inside(fingerprint?)
Why is the image not showing up?
<%= image_tag('Lab_Potion.png', :style => "z-index:19; position: relative; float: right;") %> will work. get rid of the space in the file name too, if not just for my sanity.
The random numbers are like a security feature and on each precompile the numbers end up changing. It's more complicated than that, but that is the gist.
And lastly, i doubt you have a img folder as well.

Corrupt handlebars template, with emberjs

Attempting to precompile a ember-handlebars template via gruntjs and contrib-ember-handlebars.
However, I am seeing a malformed template:
<section>
<div class="center">
<div class="logo-container">
</div>
<div class="misuseAct">
<script id="metamorph-0-start" type="text/x-placeholder"></S'+'CRIPT>
<h1>Super app</h1>
<p>The best app ever...</p>
Proceed
<script id='metamorph-0-end' type='text/x-placeholder'></S'+'CRIPT>
</div>
</div>
</section></script></div></div></section>
I am only seeing this on mobile phone browsers and with Ember minified, it works fine with Ember debug, on all devices and browsers.
Versions:
Grunt: 0.4.1
Grunt-CLI: 0.1.9
contrib-ember-handlebars: 0.6.0
Handlebars: RC-4
jQuery: 1.10.2
Ember.js: RC-6
Ember-Data: 0.13
I'm not sure if this is your problem but it seems very similar to my situation.
Ember, Handlebars, Contrib-Ember-Templates produce malformed templates on mobile browsers

not allowed to load local resource image file:///C:/uploads/images

I'm trying to get a photo URL but I get a 'no allowed' error message.
The URL comes like C:\\upload\images, but on chrome it looks like like C://upload/images.
How can I solve this problem?
#foreach (Product pro in Model.Products)
{
<div class="col-lg-4 col-md-6">
<div class="single-product">`enter code here`
<img class="img-fluid" src="#pro.ThumpNailPicture" alt="">
<div class="product-details">
<h6>
#pro.Name
</h6>
I'm not quite sure what you are asking, but in general it is best to serve content over HTTP rather than directly from local disk. This can be done either via the wwwroot folder or a dedicated static content server.

Resources