Search code examples
rubysinatrazurb-foundationsinatra-assetpack

Sinatra app - Where to place Zurb Foundation?


I am following this sinatra recipe (Foundation framework + Compass) and have always been unsure, when implementing foundation, of where I should place these files.

My Sinatra app has the structure:

sinatra_app/
|
|----app/
|----config/
|----models/
|----views/
|----etc...

By running foundation new project_name from sinatra_app, I have folder project_name within my app.

I'm just a bit confused if I should just name this folder 'foundation' and have it build out the assets accordingly.

Or should it actually live outside of my sinatra app and have compass build the assets into the sinatra app folder structure?

From the tutorial, it seems as though all of the foundation files just live in the actual root of the sinatra app which doesn't seem like it would be good at all? (with all those extra files generated by foundation - humans.txt, index.html, README.md etc etc)


Solution

  • I compiled that tutorial with the idea that one would create the foundation project using the foundation new command and then create the app inside that newly created app folder. I thought it would be better for foundation users who are new to Sinatra. If you think this is confusing, be sure to add an issue over at the GitHub repo or send in a PR.

    To answer the question, I don't think there's any hard and fast rule — at least nothing Sinatra enforces — as to where the public assets should lie. If you follow the Rails' or any other similar framework's convention, they usually stay inside the app folder. You could opt for the following structure if you think keeping foundation assets separate from the app assets ( which is the way I'd prefer too ), then you could do something like this:

    app_folder/
    |
    |---- app/
    |---- config/
    |---- models/
    |---- views/
    |---- vendor/
    |--------|
    |--------|---- ruby/               - used by bundler.
    |--------|---- assets/
    |--------|------|
    |--------|------|---- foundation/  - the foundation related files go in here.
    

    But yes, this would require moving around — or removing — some folders/files.

    Or, you could simply use the project_name folder from the app's root directory.