Where do you place documents belonging to a Rails app project? - ruby-on-rails

For every project it's like having two parts: the Rails application and then all documents and pictures related to it.
I wonder how you organize them both.
Do you put everything under the same project root folder and apply Git on that folder or don't you protect your documents with Git at all?
Then, what if the docs are too sensitive or only for owners of that project. Then I probably should't have it under the same folder right?
How have you structured both your Rails code and belonging business documents?
Share your solutions!

If you're deploying with capistrano, as a lot of Rails apps are, the standard solution seems to be to keep these sorts of assets within the shared folder, and then get cap to symlink them into the application at the point of deploy.

Related

Is it possible to keep different folders for different applications in the root level of RoR project

This is what I'm trying to achieve. I want to build an application with an admin and client portal. So I want to build a single RoR application for both these portals and I would like to keep the code of each portal separated at the root level. So basically following is the folder structure I want to have in my project.
/admin
/client
/modals
/config
/db
...
...
So I want to keep controllers, views, and other stuff relevant to each project in each folder separately.
So I want to move the modal folder to the root level as well. I read about the namespaces in RoR, but as I understand I'm unable to do it with namespaces alone. I guess I need to do some configuration level changers, don't I?
Please let me know if there is a way to do this.
Thank You.
What you're suggesting sounds like 5 Rails apps running independently. Does each one of those directories have its own Gemfile, database?
It would be possible to do what you want, but it will almost certainly be more trouble than it's worth. You'll have to override some path configurations, make adjustments to connect the models/views/controllers directories for each entity (https://guides.rubyonrails.org/action_view_overview.html#view-paths), and probably much more. Rails is an opinionated framework and it doesn't do things like this gracefully.
The 'Rails' way to do it would be to:
Add some namespace routes for each of your directories
Add app/models/admin app/views/admin app/controllers/admin etc. directories
Namespace your model/view/controller files. e.g. class Admin::SomeController < ApplicationController
If each of those is really its own app, then you would probably want to create a repository for each of them so that they're in version control separately.

Where is the .well-known folder on Heroku going to be, for a Rails 6 website?

I've created a website using Rails 6 on Heroku. I need to drop a file into /.well-known/ but I've no idea where that might be.
I created a folder with that name in the root of the project and checked it in to git, but it doesn't show up there.
It seems that I should use a route to do this, but I don't have a handle on the syntax to use. I basically need to expose a /.well-known/longhashedstring.txt to a 3rd party service for about a minute.
See above answer from Sharj. Put your .well-known folder in /public for Rails 6 and all is good.

Is it possible to change the name of the "app" folder in a Rails application?

When using Rails to only write an API, the term "app" seems less appropriate than something like "api". Is it possible to configure Rails to use a different folder besides "app" to load controllers, models, etc.? Preferably, I'd like my frontend code(outside the Rails asset pipeline) to live in "app", so creating a symlink isn't a preferable solution.
You can probably get it working by adding some hacks and fixes here and there. And then it will break again with the next gem/tool/IDE/plugin/...
Rails is strongly based on conventions, the app directory is one of them. Leaving as it is will save you lots of troubles.

Rails folder structure

I have a script which is using rspec tests for automation of the rails app. I don't want to put the file "automation.rb" in the spec folder or in the lib folder (don't want a gem for this code).
My question is: Can we have custom folders in addition to the standard ones in the rails directory structure.
Eg. a folder like automation in the root directory of rails app.
Yes, you can have any number of custom folders within your app structure.
The thing to be aware of here, is that if you're going to use code from these folders (why would you have them otherwise?), you'll have to load it.
To not mess things up much, you can add these folders under /app directory - anything defined there is automatically loaded in all environments.
As to scripts - indeed, you can just store them under the scripts folder in root directory - it's a common practice (at least I've seen it used in projects I have worked on).

EngineYard : Segregating the code & assets

Am using EngineYard to host my Rails 3.2 app. This application allows users to post images/assets. I save them in the public directory (using Paperclip Gem). Now, my problem is that - with a new deployment, I am having to manually copy over the assets to the CURRENT version.
Though, I could use AmazonS3, I still want to figure out if there is a way in EngineYard which lets me save/serve the assets from a different directory than the code, say /data/assets.
Please, let me know if you see any other alternate implementations too.
Typically your structure would look like
/data
myapp/
shared/
images
releases/
20120613000000
20120601000000
...
current (symlink to one of the releases)
When you deploy, you symlink public/images to shared/images and so your images always get stored in a non release dependant location.
I would encourage you to use something like s3: you'll make things a lot easier for when you want to host the app on multiple instances.

Resources