deploy first rails app

Is there a tutorial for deploying a new rails app? I've looked around and I don't see anything. I'm looking for a simple hello world rails app. The simpler the app the better.
What needs to happen for the db to work? Is there a way to connect to create a DB, and run migrations without too much fuss?
72 Replies
Percy
Percyβ€’2y ago
Please provide your project ID or reply with N/A. Thread will automatically be closed if no reply is received within 10 minutes. You can copy your project's id by pressing Ctrl/Cmd + K -> Copy Project ID.
luna
lunaβ€’2y ago
Is there a tutorial for deploying a new rails app?
If rails works with nixpacks it should be as simple as adding the repo as a new project and thats it.
What needs to happen for the db to work?
What do you mean by this?
Is there a way to connect to create a DB
Have you had a look around on the site and/or or docs yet? You can add a DB just like any other service with the + button within a project.
Percy
Percyβ€’2y ago
No project ID was provided. Closing thread.
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
Wow.. fast close. There's nothing that I found that indicates how to connect a PG database to the app.
luna
lunaβ€’2y ago
luna
lunaβ€’2y ago
what do you mean?
luna
lunaβ€’2y ago
How To Use PostgreSQL with Your Ruby on Rails Application on Ubuntu...
A PostgreSQL database is a robust and flexible choice for your Ruby on Rails application. In this tutorial, you will set up a Ruby on Rails development envir…
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
Ah.. sorry.. I meant inside the app docs.
luna
lunaβ€’2y ago
likely because its not any different to any other postgres db.
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
True.. setting up PG on a heroku deploy was zero steps. Fly.io... zero steps
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
git push heroku master is zero steps. I've never had to change a thing.
luna
lunaβ€’2y ago
I mean you click on a button to make the postgres, you copy details, profit?
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
Yep.. but no zero tables.
luna
lunaβ€’2y ago
this is sounding like a programming issue not a railway issue. I'd suggest reading up on how postgres works.
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
I mean all good I'm figuring out what's missing. Just not finding it in docs. In heroku and fly.io we have to include a procfile. this tells the app to run migrations on deploy. I don't see anything in the docs on railway.app that indicate how we run migrations..
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
Right... but there's no mention of this in the "rails getting started" guide..
luna
lunaβ€’2y ago
is that a railway docs or ?
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
Nope..
luna
lunaβ€’2y ago
https://guides.rubyonrails.org/v3.2/migrations.html I mean it is on their site... πŸ’β€β™€οΈ
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
there is no "rails getting started" doc. Ah.. I don't need to know how to migrate a db locally on heroku or on fly.io.
I'm not migrating from heroku to railsway.app, so why would i read about how to do that. What I am trying to figure out is, how do I "create new rails.... " to "here's my todo app" As I said.. I'll figure it out, but a "getting started" doc is needed. the "copy values" for the DB settings took me a few seconds of googling. It's not that it's hard.. it's that I didn't know I needed to do it.. And right now, I don't know how to run migrations. So I'll google around and eventually come to a "Oh here it is"..
luna
lunaβ€’2y ago
I mean the rails guide's second section is talking about migrations..
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
those are getting started with rails. Yes But, they're not related to railway.app... There's no guide. Question.. How do I run migrations in railway.app ? I'm not new to rails. I'm new to railway.app Is this chatgpt? ha ha.. Rails for 10 years.
DevOps for 0 years. Railway.app for 10 minutes.
LaCrak27
LaCrak27β€’2y ago
from what luna said, if rails is supported on nixpacks, just make a github repo with your app and then point railway to there when creating the project after that it should deploy after you push into your repo automatically for the db i have no idea about rails, so i cannot help
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
It worked a treat.. but there was no mention of running migration. I did manage to connect the app to the DB, but there are no tables there. So the queries fall over.
LaCrak27
LaCrak27β€’2y ago
yeah, the db is brand new you need to create a table
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
Sure.. how? I mean with migrations. I can write the sql to create the tables, but that seems like a backwards way to use something rails has had for > 10 years.
LaCrak27
LaCrak27β€’2y ago
i really do not get what the issue is, just query the db
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
The DB has no tables. Rails devs don't typically run raw sql.
LaCrak27
LaCrak27β€’2y ago
but... what do they run then again i have no idea about rails
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
We use rails migrations to do it. Ah.. coo when you create atable in rails, you don't write the sql to do.. A tool generates the sql.. when you alter the table a took creates the sql to alter the table.
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
Over time you have dozens of little files that are call migrations.
LaCrak27
LaCrak27β€’2y ago
a quick gogle search showed this to me
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
100% That's it.. perfect.
LaCrak27
LaCrak27β€’2y ago
dude it was the 2nd result on google
luna
lunaβ€’2y ago
https://guides.rubyonrails.org/v3.2/migrations.html like i said i think you may want to learn how rails migrations work.
LaCrak27
LaCrak27β€’2y ago
or actually research it, googling is not hard at all, and if i, who know nothing about rails, could find the answer in a search, so can you :)
luna
lunaβ€’2y ago
i also have never used rails. hence why i suggested using the guide they provide.
LaCrak27
LaCrak27β€’2y ago
yeah, documentation is key, especially for something so broad welp, glad its resolved now, thats what matters
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
Mate.. as i said.. it's not a problem with rails.. I can and do... but railway.app has nothing on how to run migrations. No rails dev would ever run sql directly. It's not safe.
LaCrak27
LaCrak27β€’2y ago
yeah but the problem isn't on railway, a railway db is just like any other one and expects to be treated as such its like if you hosted your db on a VPS you need to learn how to use it
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
right.. so locally I install PG and then install rails.. then I run rails db:migrate. This spins up rails, connects with the db and runs the sql.
LaCrak27
LaCrak27β€’2y ago
huh? no! the db is on there already no need to make one of your own
luna
lunaβ€’2y ago
bud.. go and read the rails guide.. it's the second chapter.
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
I don't have an issue with doing it on locally.. Ya'll not listening. How do I get my rails app to run the migrations. on railway.app.
LaCrak27
LaCrak27β€’2y ago
that is a problem with rails, go look at rails docs the platform of the db doesnt matter literally the same way that if you used neon.tech, or ANY other way to host your database
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
Okay.. how about this.. How can I ssh into my app?
luna
lunaβ€’2y ago
you cannot railway is not a VPS service but a container service. you should not be SSHing into containers.
LaCrak27
LaCrak27β€’2y ago
this, if you want a vps railway is not your choice
codico
codicoβ€’2y ago
you can use railway run to run scripts: https://docs.railway.app/develop/cli
Railway Docs
CLI | Railway Docs
Documentation for Railway
luna
lunaβ€’2y ago
just like every other db you would add the DATABASE_URL to your local project, you would then run the migrations. or have them run when your app starts. this is the same for all rails apps.
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
there.. there.. That's the answer.
LaCrak27
LaCrak27β€’2y ago
man we've told you like 6 times
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
How do I have something run when my app starts?
luna
lunaβ€’2y ago
if that's the answer its the same thing we've been saying since the start..
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
Not once, did you explain how to run something when the app starts.
luna
lunaβ€’2y ago
you never asked that you asked how to run migrations
LaCrak27
LaCrak27β€’2y ago
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
I asked how to run migrations on railsway.app
luna
lunaβ€’2y ago
yeah... the same way you do on all sites..
LaCrak27
LaCrak27β€’2y ago
ok is there a language barrier here?
luna
lunaβ€’2y ago
were going around in circles now
luna
lunaβ€’2y ago
Railway Docs
Deployments | Railway Docs
Documentation for Railway
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
On other cites I add procfiles. Could be language thing.
luna
lunaβ€’2y ago
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
That's what I've been looking for πŸ™‚ That runs the migrations πŸ™‚
luna
lunaβ€’2y ago
sure
LaCrak27
LaCrak27β€’2y ago
ok, please, before asking people in the server, look at the docs 1st it saves time for you and us
.jackyfrost_2023
.jackyfrost_2023OPβ€’2y ago
Tis still not a "rails getting started.". But once I suss it all out, I'll write one πŸ™‚ It's always the little unknowns that I don't know to ask. Hey o.. Ya'll should have just said there's a rails template that can be imported and run. It's a fast way to get started. :). Templates. Woot
Want results from more Discord servers?
Add your server