Ruby on Rails Wednesday, July 25, 2018

Got some issues not sure how to fix.

My application.html.erb in Production on local system

Has the following code. Comes up with the error '(index):39 Uncaught ReferenceError: play is not defined   at onload ((index):39)"

<!DOCTYPE html>
<html>
  <head>
    <title><%= full_title(yield(:title)) %></title>
    <meta name="turbolinks-visit-control" content="reload">
    <%= render 'layouts/rails_default' %>
    <%= render 'layouts/shim' %>
  </head>
  <body onload="play()">
    <%= render 'layouts/header' %>
    <div class="container">
      <% flash.each do |message_type, message| %>
        <%= content_tag(:div, message, class: "alert alert-#{message_type}") %>
      <% end %>
      <%= yield %>
      <%= render 'layouts/footer' %>
      <%= debug(params) if Rails.env.development? %>
    </div>
  </body>
</html>

Not sure how to fix that one?

In Heroku I get this error 'GET https://morning-caverns-39088.herokuapp.com/assets/blackJack.js 404 (Not Found)' which m,eans it can't find the assets/blackJack.js file

My BlackJack.html,erb file is as follows

<script type="text/javascript" src="assets/blackJack.js" ></script>

<div id = "blackJackgame">
<h2>Playing Black Jack</h2>
<div id = "blackJackcontrols">
<div class ="blackJackdealer"><button class = 'button' >Dealer</button></div>
<div class = "blackJackplayer"><button class = 'button' >Player</button></div>
</div>
<div id = "blackJackcards">
<div id="blackJackdealersCards">
<span id = "BD0"></span>
<span id = "BD1"></span>
<span id = "BD2"></span>
<span id = "BD3"></span>
<span id = "BD4"></span>
<span id = "BD5"></span>
<span id = "BD6"></span>
<span id = "BD7"></span>
</div>

<div id="blackJackplayersCards">
<span id = "BP0"></span>
<span id = "BP1"></span>
<span id = "BP2"></span>
<span id = "BP3"></span>
<span id = "BP4"></span>
<span id = "BP5"></span>
<span id = "BP6"></span>
<span id = "BP7"></span>
</div>
</div>
</div>


<div id = "blackJackbottomControls">
<div class ="blackJackplayButton"><button  class = 'button'  onclick="blackJackplayAgain()">Play Again</button></div>
<div  id = "blackJackmoneyValue">Players Money is $5000</div>
<div id = "blackJackplayersReturn">Players Card Total is 0</div>
<div id = "blackJackmessagesValue">Messages</div>
<div class="blackJackbeat">
<form name ="subscribe" id="subscribe_frm" action="#">
<input  class = 'button'   type="button" id = "blackJackbeatenterBeat" name="submit" value="Enter Beat"  onclick="blackJackgetBeat()" /> 
<input  type="text"  name="beat" id="blackJackbeatName" /> 
</form>
</div>
<div class = "hitNoHit">
<input  class = 'button' type="button" id = "hit" name="submit" value="Hit"  onclick="hit()" />
<input  class = 'button'  type="button" id = "nohit" name="submit" value="No Hit"  onclick="noHit()" />
</div>
</div>
<script>
function play()
{
blackJackshowCardInitialCards();
playGame = true;
return dealerCount,playerCount,playGame
}
</script>

My assets.rb file in config/initializers looks like this

# Be sure to restart your server when you modify this file.

# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'

# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
Rails.application.config.assets.paths << Rails.root.join('node_modules')

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )

Rails.application.config.assets.precompile += %w( game.scss )
Rails.application.config.assets.precompile += %w( blackJack.js )
Rails.application.config.assets.precompile += %w( poker.js )
Rails.application.config.assets.precompile += %w( yaghtzee.js )
Rails.application.config.assets.precompile += %w( mastermind.js )

My _rails_default.html.erb file in views/layouts looks like this

<%= csrf_meta_tags %>
<%= stylesheet_link_tag    'application', media: 'all','data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>

If you can find why the function play() can't be seen and why the javascript files in Heroku can't be find that would be great.

i put the links like <script type="text/javascript" src="assets/blackJack.js" ></script> for  BlackJack.html,erb in  BlackJack.html,erb because some function names were too similar causing issues.

Cheers Dave


On Thu, Jul 26, 2018 at 4:42 PM, Eric Jesse Knutsen <dracorna@gmail.com> wrote:

Anything in browser javascript console? Is anything not being served properly? And, dumb question time but we all have these kind of moments, did you remember to precompile, and are all your JS libraries set to have pointers to the compiled locations of assets?

 

Cheers,

 

Jess

 

 

From: David Merrick
Sent: Thursday, July 26, 2018 12:24 AM
To: Ruby on Rails: Talk
Subject: [Rails] Heroku and Javascript

 

I have built a games website in Rails. Runs run on local system. But when deployed to Heroku the Javascript requests either run slow or freeze. Often the whole page freezes. I'm only using one Dyno as I'm still in the testing phase.

 

Heroku doesn't have any suggestions to fix the problem

 

Slug size on Heroku is 36.5. MiB of 500 MiB

 

Cheers Dave

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/a26ccf22-ab23-4a07-a354-cd861ae9aa37%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

 


Virus-free. www.avast.com

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5b595131.1c69fb81.a9594.1cec%40mx.google.com.

For more options, visit https://groups.google.com/d/optout.



--
Dave Merrick

Daves Web Designs

Website http://www.daveswebdesigns.co.nz

Email merrickdav@gmail.com

Ph   03 216 2053

Cell 027 3089 169

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CA%2B%3DMcKaFV99bRhTyvS5XaYgUoNMA4aYGdgyR-WPebo8CxxnQJg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment