Permission denied - /app/public/javascripts/fancy_box.js Heroku - ruby-on-rails

I am trying to deploy my application on Heroku. I managed to get to this point but it crashed on the Fancybox.js call.
I have no idea what this means. Can someone help out?
THanks in advance.
ActionView::TemplateError (Permission denied - /app/public/javascripts/fancy_box.js) on line #10 of app/views/layouts/board.html.erb:
2011-03-31T09:02:04-07:00 app[web.1]: 7: <%= stylesheet_link_tag "reset", "style", "subscription", "form-style", "style-admin" %>
2011-03-31T09:02:04-07:00 app[web.1]: 8: <%= javascript_include_tag :defaults %>
2011-03-31T09:02:04-07:00 app[web.1]: 9: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
2011-03-31T09:02:04-07:00 app[web.1]: 10: <%= include_fancy_box %>
2011-03-31T09:02:04-07:00 app[web.1]: 11: <%=javascript_include_tag 'jquery.form', 'upload' %>

include_fancy_box essentially writes out a lot of javscript_include_tag:
def include_fancy_box(*args)
content = javascript_include_tag('jquery.fancy_box/jquery.fancybox-1.2.1.pack.js',
'jquery.fancy_box/jquery.easing.1.3.js',
'jquery.fancy_box/load_fancybox',
:cache => "fancy_box")
content << "\n#{stylesheet_link_tag('jquery.fancybox.css')}"
end
If these js files don't exist then you'll have an issue as you can't write to file system on heroku. I suggest you ensure that the files are in javascript folder before you push to heroku

Related

Rails 5.2.4.3: I get errors accessing assets including: Can't resolve image into URL: undefined method `+' for nil:NilClass

I have a Rails 5.2.4.3 app that has been working well until yesterday morning. I made a minor text change and attempted to upload the change to Heroku without testing. DON'T DO THAT. The assets didn't compile. When I executed this is localhost I got the following error.
ActionView::Template::Error (Can't resolve image into URL: undefined method `+' for nil:NilClass):
2: <p class="text-center text-cat"><%= "#{t :home01}" %><br><%= "#{t :home02}#{t :space}:" %></p>
3: <div class="row">
4: <div class="col-12 col-sm-8 offset-sm-2 col-md-6 offset-md-3 col-lg-6 offset-lg-3 col-xl-6 offset-xl-3" align="center">
5: <p class="py-2"><%= link_to image_tag("youtubevideo.jpg", class: "img-fluid", alt: "#{t :about_us}"), "https://www.youtube.com/watch?v=PrAcKje2MS0", target: "_blank" %></p>
6: </div>
7: </div>
8: <p class="text-center text-cat"><%= "#{t :home03} #{t :home04}" %></p>
app/views/pages/home.html.erb:5:in `_app_views_pages_home_html_erb__2887808543043751872_20140'
Started GET "/" for ::1 at 2020-06-05 11:05:33 -0500
Processing by PagesController#home as HTML
Rendering pages/home.html.erb within layouts/application
Rendered pages/home.html.erb within layouts/application (5055.4ms)
Completed 500 Internal Server Error in 5208ms (ActiveRecord: 0.0ms)
I didn't find much about this error that didn't include gems that I'm not using in my app or using earlier versions of Rails. This is the only one I found but the solution didn't work. This is the error I got when I precompiled the assets.
rails aborted!
NoMethodError: undefined method `+' for nil:NilClass
I thought I would rename the images on this view and try to run my application. I got the same error on my stylesheet.
ActionView::Template::Error (undefined method `+' for nil:NilClass):
15: <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
16: <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
17: <meta name="wot-verification" content="3402293318de5ef4db02"/>
18: <%= stylesheet_link_tag "application", media: "all" %>
19: <%= csrf_meta_tags %>
20: <%= favicon_link_tag "/favicon.ico" %>
21: <%= render 'layouts/shim' %>
app/views/layouts/application.html.erb:18:in `_app_views_layouts_application_html_erb___3180930056003916447_19580'
I replaced my assets folder and the view from a backup before I made my changes and I still get this error.
I have looked at the security of my assets folder on my computer and it looks fine.
What else can cause this error?
I renamed all my images and recreated new files from scratch in the other asset folders. My application works as expected.
I still don't know why Rails from time to time stops can't find an asset file. Renaming it usually fixes the problem. This is the first time this has happened to every file in my assets folder.

Errno::EACCEs...something to do with 'Sprockets'

Can anyone tell me how I can resolve this error that has started appearing in my app? Thanks for any help.
Soemthing to do with...Sprockets? My app was working fine until recently. With regards 'line 9', application.js is in the admin folder, in Assets, as it should be, and I haven't changed the code.
Errno::EACCES in Admin/users#index
Showing /home/mycompaq/myapp/app/views/layouts/admin/application.html.erb where line #9 raised:
Permission denied - /home/mycompaq/myapp/tmp/cache/assets/sprockets%2Fb250691303afe8bdea5daa9e24412c8020130818-2524-njp18c-0 or /home/mycompaq/myapp/tmp/cache/assets/D5C/180/sprockets%2Fb250691303afe8bdea5daa9e24412c80
Extracted source (around line #9):
6: <title><%= content_for?(:title) ? yield(:title) : admin_area_title %></title>
7: <%= csrf_meta_tags %>
8: <%= stylesheet_link_tag "admin/application", :media => "all" %>
9: <%= javascript_include_tag "admin/application" %>
10: <% if #include_goole_maps %>
11: <script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=true&libraries=places"></script>
12: <% end %>
Rails.root: /home/mycompaq/myapp
Application Trace | Framework Trace | Full Trace
app/views/layouts/admin/application.html.erb:9:in `_app_views_layouts_admin_application_html_erb___1652810648_69910752274140'
Easy solution. Just deleted the tmp folder and its contents in my application folder with:
rm -r tmp
Probably a good idea to back it up elsewhere, first, just in case.

error when precompile assets with turbo-sprockets-rails3

I have installed turbo-sprockets-rails3 gem for precompile assets with capistrano.
I have added load 'deploy/assets' to my Capfile and the deploy finish fine.
However when I try load my app on remote server I can see inside my production.log file the next errors:
ActionView::Template::Error (bootstrap-modalmanager.js isn't precompiled):
7: <%= display_meta_tags :site => "9cvs" %>
8: <%= stylesheet_link_tag "application", :media => "all" %>
9: <%= javascript_include_tag "application" %>
10: <%= javascript_include_tag "bootstrap-modalmanager" %>
11: <%= javascript_include_tag "jquery.back_to_top" %>
12: <%= javascript_include_tag "swfobject" %>
13: <%= csrf_meta_tags %>
bootstrap-modalmanager.js is found inside vendor/javascripts/ folder. Also I have css files inside vendor/stylesheets/ and swf files inside vendor/flash/ folder.
How can I precompile this assets correctly?
You need in your production.rb
config.assets.precompile += ['bootstrap-modalmanager.js', 'jquery.back_to_top.js', 'swfObject.js']

"TypeError: Cannot call method 'write' of undefined" in production mode

When I run my little app on my local system everything works fine. When I move to production I get the error 500 message (We're sorry, but something went wrong.). My production.log fiel is showing this:
Started GET "/" for 79.203.113.136 at 2012-11-13 13:54:06 +0100
Processing by DayviewController#index as HTML
Rendered dayview/index.html.erb within layouts/application (0.4ms)
Completed 500 Internal Server Error in 1783ms
ActionView::Template::Error (TypeError: Cannot call method 'write' of undefined
at /tmp/execjs20121113-27948-1cczq8s.js:5043:20
at /tmp/execjs20121113-27948-1cczq8s.js:5057:16
at /tmp/execjs20121113-27948-1cczq8s.js:1:92
at Object.<anonymous> (/tmp/execjs20121113-27948-1cczq8s.js:1:109)
at Module._loadContent (node.js:667:21)
at node.js:695:20
at node.js:304:23
at node.js:756:9
(in /home/www/pvdaheim/app/assets/javascripts/jquery-1.8.2.min.js)):
5: <%= stylesheet_link_tag "application", :media => "all" %>
6: <%= javascript_include_tag "application" %>
7: <%= javascript_include_tag :defaults %>
8: <%= javascript_include_tag "jquery-1.8.2.min", "jquery-ui-1.8.23.custom.min", "jquery.ui.datepicker", "rails", "highcharts", "highstock" %>
9: <%= csrf_meta_tags %>
10: </head>
11: <body>
app/views/layouts/application.html.erb:8:in `_app_views_layouts_application_html_erb___1022895261_93021610'
I don't have a file called /tmp/execjs20121113-27948-1cczq8s.js. I found some similar issues in the forum but none of them was helpful for me to fix mine.
Thanks & Regards, Andreas
Here is my index.html.erb:
<div id="container2" style="height:500px; background-color:#999999; border:thin solid">
</div>
<script type="text/javascript" src="./pv_andreas/wr.js"></script>?
<script type='text/javascript'>//<![CDATA[
$(function() {
var chart = new Highcharts.StockChart({
... highstock stuff rendered to container2...
});
//]]>
</script>
And here is my routes.rb:
Pvdaheim::Application.routes.draw do
get "dayview/index"
root :to => 'dayview#index'
end
Remove get "dayview/index" in your routes file and it will work.

Rails can't generate Tempfile

I installed my rails-app via Passenger on my apache but I'm getting a strange error
cannot generate tempfile `/var/rails/wo42/tmp/cache/assets/sprockets%2Fb94bb762c37131f8bb65f843c621876720120401-29970-ha7f1p-9'
Extracted source (around line #24):
21: <%= stylesheet_link_tag "application" %>
22:
23: <!-- Included JS Files -->
24: <%= javascript_include_tag "application" %>
25:
26: <%= csrf_meta_tags %>
27: </head>
It seems to be something with the rights but I set /var/rails/wo42/tmp to chmod 777?
I just ran into this myself. Not sure if this will be a permanent fix, but here is what got me past it:
rake tmp:clear

Resources