Rails 7.0.0alpha2, esbuild, tailwind and devise

I recently took a go at starting a new Rails application with Rails 7.0.0alpha2. It went pretty well aside from a few things which I’m going to share with you and point you towards the solutions I came across.

The first step was to get the new version of Rails. You can head on over to https://rubygems.org/gems/rails/versions/7.0.0.alpha2
and grab the install command to get Rails 7 installed.

Next I started a new rails app based off of this video that DHH put out:

I ran the same commands but did not get the same results. The main issue was that the build script commands needed for esbuild and tailwind did not get added to the package.json file. A friend pointed out to me, when I shared this on Twitter, what was most likely the cause (the npm version I was using) which you can find in the comments along with the scripts that I had to add before I learned of the possible cause (Thanks again so much Andrea!):


With these issues resolved I was off to the races with tailwindcss running in JIT mode as well! Really cool and despite the issues I had, it was still the easiest time I’ve had installing tailwind in a rails app not to mention getting JIT to work. I basically did nothing 🙂

Next was an issue when pulling in Devise. Here’s the issues you might run into as well if you’re following along:

If you run into an issue when running rails generate devise:install, there’s a solution branch you can use listed in the thread linked below:


You’ll want to add this to your gemfile to use this branch:

gem "devise", github: "ghiculescu/devise", branch: "patch-2"

Run bundle again and then you can move on.

Next you’ll probably run into:

Error in lib/devise.rb:316:in get: undefined method constantize for ActiveSupport::Dependencies:Module (NoMethodError)

as noted here, which also provides some guidance on a fix:

I ran

bundle open devise

and then made this change to this method which starts on line 315 in devise/lib/devise.rb:
Change from:

def get


def get

Hope this helps get you up and running with Rails 7 and the other tools mentioned quickly and enjoying the experience! As time goes on I’m sure a lot of these issues will get worked out thanks to the work by the great folks of the open source community. To all of those folks I send you my warmest thank you!

Source link