This content originally appeared on DEV Community and was authored by Collin
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:
https://www.youtube.com/watch?v=JsNtLiph87Y
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!):
https://twitter.com/collin_jilbert/status/1439316892351705096
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:
https://github.com/heartcombo/devise/pull/5357#pullrequestreview-656251176
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:
https://github.lancex.top/heartcombo/devise#issue-975972076
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
ActiveSupport::Dependencies.constantize(@name)
end
To:
def get
@name.constantize
end
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!
This content originally appeared on DEV Community and was authored by Collin
Collin | Sciencx (2021-09-18T23:48:10+00:00) Rails 7.0.0alpha2, esbuild, tailwind and devise. Retrieved from https://www.scien.cx/2021/09/18/rails-7-0-0alpha2-esbuild-tailwind-and-devise/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.