Running rails new as a "newbie"

Introduction & Context

I just wanted to start by first saying thank you to everyone involved in this initiative, I truly think this is such a wonderful way to bring things to the surface which otherwise would get lost for various reasons. This is such a fantastic example of some of the things that I think makes this community truly special and stand out from others in the field.

I’ve been playing around with Rails now for a couple of years on the side but I think it seems somewhat relevant to mention that I am not and never have been a professional developer. I work full time in marketing and as such I am coming to this discussion from the point of view of someone who seems to fit the audience you are trying to reach.

I feel like I have taken a lot from the Rails community in terms of knowledge and this is one of the first ways I have felt comfortable giving anything back no matter how small this may be. However, this is a serious effort to try and document the ways in which I feel Rails could be improved to newcomers and others like myself who “aren’t experts”.

Issue #1: Running rails new is usually a 45+ minute ordeal for me

I will preface this by saying that I have never seen anyone talk about this as a metric before but I consider it to be a reasonable one from the perspective of a framework. The time it take for me to get from “OMG I have a cool idea” and writing my first line of business logic is usually somewhere between 45 minutes to an hour.

Two quick points come to mind here for me:

  1. That is more than enough time to kill a substantial amount of motivation and generally feels like a big friction point to me.
  2. That is a world away from the Rails 15 minute blog reputation that proceeds it (I will concede this isn’t necessarily a fair comparison).

It might be fair to assume that I am doing all kinds of crazy customizations and that is perhaps why it takes so long so I wanted to explore this from the perspective of what specifically happens in a scenario like this.

As a developer my primary motivation is to setup a project with as many “best practices” as I can from the start.

I put best practices in quotes here because they are almost exclusively opinions but they aren’t fringe ones by any means as far as I can tell. So this involves first running:

rails new app_name --webpack=stimulus --database=postgresql --skip-sprockets --skip-coffee --skip-test

Followed by the these 5 steps (each of which has a number of subtasks):

  1. Using a test framework other than minitest (RSpec is my personal preference since this is how I learned through most books and online tutorials so it is what I am comfortable with).
  2. Moving all asset handling to use Webpacker rather than the asset pipeline because I want to take advantage of things like PostCSS and other modern approaches to front end.
  3. Setting up various linting tools for my Ruby, CSS and JavaScript and making sure that they run at appropriate times.
  4. A couple of gems here and there to make sure I am not shooting myself in the foot as I code like bullet and brakeman for example.
  5. Hook up my code repository to Github and if I am feeling especially daring I might add a YAML file that I stole from somewhere on the internet in order to try and run my tests in a CI kind of fashion.

Then once that is all done I have to go and write a sample controller and test to go with it just so that I can actually be confident that I really did set things up the correct way because this is a manual haphazard process that I manage to somehow screw up more often than I care to admit.

As a side note… the other month I tried to go down the path of setting up a Dockerized developer environment. That took me multiple days.

Comparing and Contrasting rails new with other mature web frameworks

A couple of weeks ago I was trying to learn some fundamental OO patterns by watching videos on YouTube where I was thrown into the world of Java for a brief moment. One of the things that struck me however was what is the equivalent experience like on a platform like Spring.

As the presenter began introducing the Spring equivalent of rails new it I had this very smug feeling of:

I can’t wait to see how they do it because Java is notoriously configuration heavy and I bet this is going to be a huge pain.

Honestly 5 minutes later I felt like a massive dick for thinking that.

The Spring experience is this quite pleasant web interface experience where you just answer a couple of questions around the kind of setup you want to work with and click go. It’s not even just bare bones setup like I described above either.

For example if your app needs to handle things like:

  • OAuth2 / PubSub / Web Components and a bunch of other common patterns
  • Deploying to any major cloud provider
  • Setting it up to work with any major observability tools like Datadog or Prometheus for example

Once again, just click the button and it is done. I was blown away.

Despite the fact that they are totally realistic scenarios they are often huge amounts of work and reading a various mish-mash of StackOverflow, outdated and conflicting tutorials, documentation and muttering “Why the fuck doesn’t this work?” to myself.

Suggestions for improvement

  • I have looked so far at a grand total of 1 other framework so far to see how they handle this problem. Collectively it would be nice to see how others are solving this problem as well in order to see what we can learn from it.
  • I have been watching this pull request from @DHH since it first turned up about The Rails Conductor because I think it’s a exceptionally nice idea. But maybe it’s scope should also consider handling something like rails new so that you can give users a really nice visual interface.
  • I feel like we should also start taking a serious kind of look at what does a “cloud native” development experience look like? There is always a challenge here of drowning in buzzword bingo but maybe we just start with a goal of fully portable development environments that work reliably.

Note: I have like 4 or 5 other suggestions like this which I am more than happy to write up. I just want to make sure that this kind of feedback and the format of it is something that is actually helpful. I didn’t want to make this post any longer than it already is.

9 Likes

Thanks so much for putting your thoughts down!

rails new app_name --webpack=stimulus --database=postgresql --skip-sprockets --skip-coffee --skip-test

Running the rails command above seems very reasonable, usually at this point you are good to go writing rails code. However some of the other gems you want to pull in results in a heavily customised app, there is just so much different opinions out there like datadog vs scoutapm vs the next cool thing.

Is bullet even necessary for example? (I never use it)

rails new with an interactive CLI is mentioned in another thread, I also feel that would be awesome. Personally I loved how nodejitsu created apps for me.

Rails conductor will go a small way into getting started, but it seems like a lot of what you mentioned has so many different options and rightly so falls way out of the scope for rails.

For example Heroku for cloud deployment, you have the option to add a plethora of “elements” like application monitoring tools (scout, new relic etc.) which will help you get your app up and running in a small amount of time. Most elements are free, especially if you are just hacking on your idea.

NOTE: I’m not affiliated to heroku but thought it was worth mentioning

1 Like

Thank you for the response!

I think there might be a little confusion there potentially? When I was talking about those kinds of customisations you were referencing it was only ever really in the context of just saying this is how Java approaches it rather than anything that I needed or was even suggesting for Rails core.

But in the section where I talked about the 5 steps that came after running Rails new I genuinely don’t know if that is considered heavily customised or not because I don’t work with Rails outside of a bit of a hobby in my spare time but I think I could rephrase my goals immediately after running rails new as:

  1. Use a different but more popular testing framework (using # of downloads according to RubyGems.org as a metric here)
  2. Use Webpacker instead of Asset Pipeline
  3. Make sure my code works

That hardly seems exotic though to me. It’s more about what needs to be done and the amount of time it takes to do that in a way that I am confident that everything is hooked up and working as it should be.

1 Like

This is VERY much the kind of thing this forum topic is designed to solicit. Thanks for putting so much thought into your feedback!

It seems like you might have a lot of good thoughts to contribute to Interactive "rails new" - #14 by joallard, which is where a lot of discussion about improving the rails new experience seems to be happening.

4 Likes