1

I made a game in JavaScript. I have a directory called Game, and it contains:

  • index.html
  • app.css
  • imgs
  • lib
  • vendor

Inside of lib I have my own javascript files. Inside of vendor I have a javascript file from a third party, that is used for a specific functionality in the game. I'm using webpack to bundle my modules, and so inside of lib I also keep my bundle.js file.

I now want to add a Rails backend to the game. I am very familiar with writing code using Ruby on Rails, but there are holes in my knowledge of where certain files should go in the directory structure.

If I transform my purely javascript/html/css game into a Rails application with a single page (the root page with the game on it), where do the files I listed above go?

Here is how I think it would be:

  • index.html would become my app/views/layouts/application.html.erb
  • app.css would become app/assets/stylesheets/application.css
  • the contents of my imgs folder would go in /public (actually it has never made sense to me why I it never works when I put my images in app/assets/images, but that's another story)
  • the contents of my lib folder would go in app/assets/javascripts (hope I don't have the same issue as with my images)
  • and the javascript file contained in my vendor folder would go in /vendor

Is this correct? Are there any other considerations to take into account?

1
  • I dont think that your javascript files which are there inside your vendor should go inside '/vendor' Commented May 9, 2016 at 13:58

1 Answer 1

1

Your app.css file should stay in the app/assets/stylesheets folder as app.css. Leave your application.css file alone as it will require the tree which includes your app.css file. Your images should remain in your app/assets/images folder so when you run "bundle exec rake assets:precompile RAILS_ENV=production" for deployment it will get precompiled and added to the public folder. Your personal js files in your lib folder should be moved to the app/assets/javascripts folder and the vendor js files should be put in the vendor js folder as you said.

In general, all assets in the vendor folder should be files/scripts done by outside sources and all personal js/css files you write should be in app/assets folders.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.