Different Folder Structure from Heroku - ruby-on-rails

I'm building an app which requires the frontend and the api to be separate. The folder looks like this
application/
.git/
frontend/
api/
Procfile
The API is a rails application so I'd like to use the cedar stack from Heroku.
When I try and push the application I get the message
! Push rejected, no Cedar-supported app detected
Which makes sense as it needs to look in a subfolder. How do I tell heroku to only use the sub folder?

The folder structure you posted doesn't look like a Rails app at all.
If you want to split the frontend from the api, you can perfectly to that at controller level by having two different namespaces.
That will generate a structure like the following one
app/
controllers/
api/
whatever_controller.rb
frontend/
user_controller.rb
whatever_controller.rb
public/
log/
db/
Procfile
... other standard Rails folders and files
The structure you have seems to represent two completely different Rails app. If that's the case, then you need to use two different Heroku app.
If that's not the case, then that could not work. I don't even think how you can start it, given that it doesn't represent a standard Rails structure.

Related

Where to put source files for a Sinatra app mounted within a Rails app

I have a standalone Sinatra app with its complete directory structure, and I have a Rails app with its own directory structure. I want to mount the Sinatra app within my Rails app by adding a mount statement in my routes file.
Where should I put the source files for my Sinatra app within my Rails directory structure to follow "best practices"? Ideally, I would want to preserve the directory structure for my Sinatra app and all its layouts, etc.
There is really no specific place. I'd put it in /lib. You can also place it in its own folder in /app, but /app has special reloading and autoloading rules.
You can place it in /lib, require the Sinatra app and mount it in the routes.rb file.

Get AWS Beanstalk to run Rails app from subfolder as opposed to root

I have a repo with the folder structure as such
root_of_repo
-app
-some_gem
-some_gem
Within the app folder is where my Rails app lives. I would like for beanstalk to deploy the rails app from within this folder. However, it keeps trying to deploy the Rails app from the root. How would I tell beanstalk to first navigate into the app folder then continue running the necessary rails actions (bundle, rails s, etc).
beanstalk is very sensitive to structure as its deployment process is mostly a bunch of shell scripts wrapped together. therefore it won't bend to your new structure.
a couple of options here:
1. adapt to the standard structure, which is also recommended by rails. don't nest "app" folders.
2. create a pre-deploy script (.ebextension) that copies your folder to the right place.

Where should I save standalone non-ruby scripts in my Rails app?

This is a simple question, but I haven't been able to find an exact answer to it anywhere.
I have a standalone Python script which I am using in my Rails app. What is the appropriate folder I should save it in according to convention, so that I can push it to production (currently running it from my computer's desktop)? I think the answer is lib/assets but I want to make sure.
I don't think there is an exact answer for this question.
If it is a ruby script, it is usually placed in lib or bin.
From the rails folder descriptions in Getting Started with Rails guide:
bin/ Contains the rails script that starts your app and can contain
other scripts you use to setup, deploy or run your application.
lib/ Extended modules for your application.
You could put it in lib/assets folder as it reflects your understanding that it is an external asset used in the system.

Change default project root - Heroku

Heroku wants a git repository in an application root directory with a Procfile. What is common best practice for creating an outer directory? Ideally, this outer directory is the root of my git repo, and it contains documentation and high level deployment documentation, in addition to the application root. Obviously - if this would mean my git repo and application root are in different places.
How do I fix this? Do I have two different git repos? Do I make a submodule? Is there a way to just tell Heroku "Hey - this isn't the application root, that directory is though!"
Thanks
The standard structure (at least for Rails apps) is to have a root folder (which is also the application's and repository's root) which contains the application code, documentation and the Procfile.
I've never seen an "outer" folder in any of the apps and I don't see how this could be a good idea. It would just make things more complex.
Example: https://github.com/railstutorial/sample_app. In Rails apps for example, the documentation lives on the doc/ directory, the README is in the root folder README.md and the Procfile is also in the root folder.

Ruby on Rails integration with Heroku/Engine Yard/similar services

I have a Ruby on Rails project that I've deployed to a PaaS service via GitHub. The Git repo is structured like so:
/ (root)
README
some random files here
src (directory)
a_folder
another_folder
my_rails_app
app (directory)
config (directory)
config.ru
db (directory)
...
Gemfile
...
Rakefile
README
...
As you can see, the Rails app is two directories underneath the root. I suppose I could move it to one file underneath root if necessary, but I definitely need to have other non-Rails files tracked under version control.
But since my Rails app isn't at the root, I'm having trouble using Engine Yard, Heroku, etc... they don't know where to find the Rakefile. I tried creating a Rakefile (https://gist.github.com/245400) and placing it at the root and src directories but it still doesn't work.
Do you know what's going on here or how to fix it?
(As requested ;-D)
If you want to deploy on Heroku/Engine Yard, etc. you might just want to put all those "other folders" within the app directory (e.g. in a folder called supporting_documents or something).
Then you can have those docs under source control AND deploy on Heroku. Also, with Heroku, you'll be able to add those additional documents to the slugignore file (http://devcenter.heroku.com/articles/slug-compiler) so they don't get compiled in the slug.

Resources