Assets pipeline issues when upgrading to Rails 3.1 - ruby-on-rails

I'm in the middle of upgrading a very old project to the latest version of rails. So I've read a ton about the changes to the Asset pipeline between rails 3.0 and 3.1, including this entire page, and I've followed all the steps in part 9. I've also read quite a few stack exchange questions dealing with what appears to be the same issue as mine. None of these are working though.
In app/views/layouts/_sidebar.html.erb I have this html:
<img id="admin_img" style="border:none"
src="/images/<%= in_server_menu ? 'expanded' : 'collapsed' %>.gif" />
After upgrading, I've changed that src= to all of the following:
src="<%= image_path(in_server_menu ? 'expanded.gif' : 'collapsed.gif' )%>"
src="/assets/<%= in_server_menu ? 'expanded' : 'collapsed' %>.gif"
src="/assets/images/<%= in_server_menu ? 'expanded' : 'collapsed' %>.gif"
src="assets/<%= in_server_menu ? 'expanded' : 'collapsed' %>.gif"
src="app/assets/images/collapsed.gif"
and numerous similar paths, but the image fails to load. The actual HTML output for the first two is
src="/assets/collapsed.gif"
which APPEARS to be correct, as my file system looks like this:
project_folder
->app
->assets
->images
->collapsed.gif
Firefox shows the default "broken image" thumbnail, though, and image info says it's 0 bytes and cannot be loaded, which makes me think it's not being found. I've restarted the server since making changes, and manually opening the file with Firefox works, so the image isn't broken.
Rails.application.assets.paths contains
/path/to/the/project/folder/app/assets/images
as well as the other assets folders.
I've confirmed that the src tag I am modifying is indeed the broken image I'm looking at, so it's nothing as simple as that.
What else can I do to make this image load? What other troubleshooting steps can I take? I am also having issues with other assets not being loaded yet that I can see when I load a page and watch the server output, but I have not yet tackled those.

try like that:-
<%= image_tag (in_server_menu ? "expanded.gif" : "collapsed.gif"), :id => "admin_img", :style => "border:none" %>

Related

Umbraco 11 - Render images

In my Umbraco 7.15.7 I'm displaying images in the Partial Views Macro Files as follow:
figure>
#if (newsItem.HasValue("articleImg"))
{
<img src="#Umbraco.Media(newsItem.articleImg.ToString()).Url" class="img-fluid news-img" alt="#newsItem.Last().photoAlt" />
}
(the reason for the .ToString() is after I switched from Obsolete to Media.Picker2 - so since it's string)
In my Umbraco 11.1 I was struggle to display the images. I tried the following and it didn't display the images, but also didn't throw an error, just didn't display the images:
<img src="#Umbraco.Media(newsItem.Value<IPublishedContent>("articleImg").ToString()).Url()" class="img-fluid" alt="#Imaging_pagesToList.Last().Value("photoAlt")" />
So I tried this one:
<img src="newsItem.Value<IPublishedContent>("articleImg").Url()" class="img-fluid" alt="#newsItem.Value("photoAlt")" />
And this one also doesn't show any image
I also tried this one (the same as above, just with # - #newsItem) , and this throw an error: "Argument 3: cannot convert from 'method group' to 'object?'":
<img src="#newsItem.Value<IPublishedContent>("articleImg").Url()" class="img-fluid" alt="#newsItem.Value("photoAlt")" />
So I tried this one:
var image = newsItem.Value<IPublishedContent>("articleImg");
<img src="#image.Url()" class="img-fluid" alt="#newsItem.Value("photoAlt")" />
And this is finally works! And I don't understand why? (why this works, and why the previous didn't work)
My question are:
Why only the last one works?
Why the first two doesn't work?
Is this is the right way to render images in Umbraco 11.1 ?
In the official documentations of Umbraco (9 and up) they suggest to render images as follow:
var mediaItem = Umbraco.Media(Guid.Parse("55240594-b265-4fc2-b1c1-feffc5cf9571"));
But they hard coding the Guid in their examples.
Not sure how to get the Guid for each node.
Please advise.
Thanks.
Please check what property editor is used; maybe it's a collection and not a single media. In that case, you will need something like:
newsItem.Value<IEnumarable<IPublishedContent>>("articleImg").First().Url()

Replace version of pdfjs-dist to version v2.10.377

I'm using the ng2-pdfjs-viewer v13.2.2 package in an Angular 10.2.4 project.
I would like to replace in the assets/pdfjs folder, the pdfjs-dist version of 2.2.171 (project original), with version 2.10.377.
The reason is because the most current version shows fewer errors in SonarQuebe.
When I do the replacement, the component continues to work normally, however, the options to disable buttons are no longer working. With the original version it worked correctly. I'm trying to disable the openFile button.
<div style="height: 1600px">
<ng2-pdfjs-viewer
#pdfViewer
*ngIf="pdfPronto"
[pdfSrc]="pdf"
download="true"
openFile="false"
print="false"
find="true"
fullScreen="false"
showSpinner="true"
>
</ng2-pdfjs-viewer>
</div>
Any tips on what I can change to make it work?

Why is modx getResources and phpthumbof showing the same thumb nail for different resources?

I have a getResources call that shows 6 items on my homepage:
[[!getResources?
&tpl=`homepageInventoryCellTpl`
&parents=`4`
&resources=`-33`
&depth=`10`
&limit=`6`
&includeContent=`1`
&includeTVs=`1`
&processTVs=`0`
&hideContainers=`1`
&showHidden=`1`
&debug=`0`
&sortbyTV=`vehicleonhomepage`
&sortDirTV=`DESC`
]]
it does work showing 6 thumbs [for vehicles] but it shows the same thumb for each vehicle!
The output tag looks like:
<img class="img-responsive"
src="
[[!phpthumbof?
&input=`[[!++gallery.files_url]][[!getgalleryAlbumCover?
&id=`[[!+tv.vehiclegallery]]`]]`
&options=`&w=300`
]]"
/>
Note that nothing is cached [!]
getResources does work correctly and returns six different images if I remove the phpthumbof bit
I've cleared all the different caches several times
[[!++gallery.files_url]] just returns the gallery path [/assets/gallery/]
[[!getgalleryAlbumCover? &id=`[[!+tv.vehiclegallery]] returns the actual name of the album cover
the /assets/components/gallery/cache/ directory is writable.
Why is it showing the same thumb for all 6 vehicles?
I had the same problem. In the end I removed phpPhumbOf and installed pThumb and problem disapeared.

Image source path in application_helper.rb in Rails

In my Rails app, I am using a img tag in Application_helper.rb, But I think Assests pipeline is not working here, So the image is not loading on the page. And Browser console show as error of "failed to load the given URL".
One line fro my code block is as :
text = "<input type='checkbox'/><img src='Icon_Bar.png' />#{r[:value]}<span class='small'>(#{r[:count]})</span>".html_safe
And it works fine, when I used any online path for the image. Please Help.
Try this,
text = "<input type='checkbox'/><img src='/assets/Icon_Bar.png' />#{r[:value]}<span class='small'>(#{r[:count]})</span>".html_safe
Add /assets/ before the image.extension.
when Icon_Bar.png in assets/images/Icon_Bar.png
Try:
<img src="<%= image_path('Icon_Bar.png') %>" />
The doc is here: http://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-image_path
Try :
<%= image_tag("Icon_Bar.png") %>
Watch out for the capital letters , they also matter in referencing to assets.

Open Flash Chart 2 not showing in Ruby on Rails

My question is about my first Open Flash Chart not displaying at all in my Rails application (2.3.5 running on Vista). I am trying to implement: http://openflashchart2.heroku.com/chart_examples/pie. All the code is in but when I load the view using the server, there's nothing there! Pull up the blank page's source code and I see:
swfobject.embedSWF(
"/open-flash-chart.swf","flashcontent_4000",
"650", "300", "9.0.0", "expressInstall.swf",
{"data-file":"/charts_ofc2%2Fpie"}, {{}}, {{}} );
but I do NOT see anything like this (this is copied from the source code of the example page):
<object type="application/x-shockwave-flash" wmode="transparent"
data="/open-flash-chart.swf" width="650" height="400"
id="flashcontent_108400" style="visibility: visible; ">
<param name="flashvars" value="data-file=http%3A%2F%2Fopenflashchart2.heroku.com%2Fcharts_ofc2%2Fpie"></object>
I think the lack of this chunk is why I'm not seeing the graph. Do you know where the problem is? Thank you so much.
Background
Setup: RoR 2.3.5 running on a Windows
machine, existing database and
project under development.
In vendor/plugins, I typed: git clone
git://github.com/korin/open_flash_chart_2_plugin.git
open_flash_chart_2
Did rake open_flash_chart_2:install
open-flash-chart.swf (265kb) is in public/
swfobject.js is in public/javascripts
json2 is in public/javascripts/json
Also did the git clone and tried to do submodule
update but it said: fatal: not a git
repository (or any of the parent
directories).
Copied controller/view code into new controller
I also named charts_ofc2 for pie chart
Haml and JQuery are installed

Resources