ruby on rails - Calling json.txt files and handling action view controller -


new ror , making sample project learn how js works in rails app using little trivia game.

in case want it, relevant code here trivia app.

now in ror app, css loads fine because added trivia.css.scss file /stylesheets javascript file because calling both:

 <%= stylesheet_link_tag    "application", media: "all", "data-turbolinks-track" => true %>  <%= javascript_include_tag "application", "data-turbolinks-track" => true %> 

so far, good. in line 347 of trivia.js though, call 2 json.txt files used populate test questions:

 // here add pairs "category_name" , file json quizzes associated each        category   var files_json = {'general':'general_json.txt', 'animals':'animals_json.txt'};  // calls method creates list categories trivia added in json  obtrivia.setcateg(files_json, 'json'); 

those 2 files test questions not loading, app not recognize quiz files. have 2 theories why trivia game breaks:

  1. i placing json.txt in wrong folder , isn't calling correctly. right now, placing in javascripts folder because line 347 doesn't call subdirectory, , application.html.erb calling in assets folder already
  2. i totally off base, , need view controller aspect tell rails parse json files.

would appreciate feedback on whether barking wrong tree.

i don't know setcateg need include of assets , js files. make sure json files inside application , folder getting required.

one other observation files passed setcateg text files, perhaps these need json files?

please post code showing how setcateg requires json files if need better answer.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -