Rails 7.0.2.2
Windows 10 Professional
So I made a new rails 7 app in windows. It no likey windows so in order to get it working I used a workaround as the 'glob pattern is not recognized' when using the ./bin/dev command. I modified the package.json to add another script:
"build": "esbuild app/javascript/application.js --bundle --sourcemap --outdir=app/assets/builds",
"build:jscontrol": "esbuild app/javascript/controllers/application.js --bundle --sourcemap --outdir=app/assets/builds",
"build:css": "sass ./app/assets/stylesheets/application.bootstrap.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules"
}
and to boot up the app as ./bin/rails I instead use foreman start -f Procfile.dev
I altered the configuration initializers/devise.rb uncommenting and changing the value.
config.scoped_views = true
Don't Judge :P
And it works fine until... I started using devise.
rails new . --javascript=esbuild --css=bootstrap
I proceeded to add the devise gem to the Gemfile
bundle install
rails generate devise:install
rails generate controller home index as per usual
I changed the rails routes accordingly. root to: 'home#index
I altered the configuration initializers/devise.rb uncommenting and changing the value.
config.scoped_views = true
Afterwards I boot the server using the command previously mentioned to verify and it works.
rails generate devise User Check.
rails generate devise:views users Check.
When styling the generated views I would refresh the browser. Nothing changed. No Styles were added. Shapoopy.
I deleted all but the model User. By way of rails destroy or manually escorting them to the recycle bin. I started the server. I stopped the server I cleared all the caches deleted every tmp file to no avail.
Then AFTER I DELETED THE VIEWS AND THE CONTROLLER with the server running, I refreshed the browser by reflex without changing the url ( localhost:3000/users/sign_up ) the default form popped right up. I checked the terminal and noticed it was pulling the views from Ruby30-x64/lib/ruby/gems/3.0.0/gems/devise-4.8.1/app/views/devise/shared/_links.html.erb and I can't get it to stop and pull from the app's views I had generated.
Rather Verbose I know. I added the workaround only for clarity and specificity.
Regards
-jaxton
Related
I tried to complete the first suggestion by typing
ruby
rails bin/dev
but I was not able to get an output (The terminal showed no output )
then I realized my code was wrong so I tried once again and typed:
rails create bin/dev
But it showed me an error and said "rails aborted!
Don't know how to build task 'create' (See the list of available tasks with rails --tasks)
Did you mean? db:create"
Then I tried the other command by typing rails in front of it but that didn't work either.
So even though my app works should I bother to solve this warning or skip past it?
TLDR: You need to build your CSS output on every Tailwind style addition so execute bin/dev in a terminal to start your rails server AND watch for tailwind changes.
Hey! Your screenshot is saying that you have successfully installed Tailwind via the tailwind-rails gem.
The end of the message provides instructions on how to build your Tailwind CSS during local development so that Tailwind styles are output to the CSS and applied to your app on localhost:3000 immediately.
Option 1: (documented in the installation output) In your terminal, execute bin/dev to start your rails server AND watch for tailwind changes. This command uses a library called foreman to run two processes, reading from the Procfile.dev that was created in your project's root directory during tailwind installation.
Option 2: (documented in this section of the README) In your terminal, execute rails s in one terminal window and rails tailwindcss:watch in a different window (separate commands)
Option 1 is simpler and probably recommended.
(Based on your screenshot, you are not on a Mac and your exact command may differ, but these work for me on a macbookpro.)
I've setup sidekiq for my application. I am placing my workers in a newly created subdirectory app/workers/. Presumably, rails is expected to autoload any subdirectories under app/. If I evaluate
puts ActiveSupport::Dependencies.autoload_paths
in a rails console, in development, it does include
".../app/workers"
In production however, the new directory is missing. Other custom folders I've placed under app/, namely services/ and validators/, do show up in the autoload_paths for both production and development.
I've seen answers to other questions that suggest restarting spring, however, this is happening in production for me.
services/ and validators/ existed the first time I deployed my app to production (using Capistrano), while workers/ is from a subsequent commit.
My unicorn deploy script included bin/ in the linked_dirs. Rails console is booted from bin so it needs to represent the current release. I removed bin/ from shared_dirs
I've setup sidekiq for my application. I am placing my workers in a newly created subdirectory app/workers/. Presumably, rails is expected to autoload any subdirectories under app/. If I evaluate
puts ActiveSupport::Dependencies.autoload_paths
in a rails console, in development, it does include
".../app/workers"
In production however, the new directory is missing. Other custom folders I've placed under app/, namely services/ and validators/, do show up in the autoload_paths for both production and development.
I've seen answers to other questions that suggest restarting spring, however, this is happening in production for me.
services/ and validators/ existed the first time I deployed my app to production (using Capistrano), while workers/ is from a subsequent commit.
My unicorn deploy script included bin/ in the linked_dirs. Rails console is booted from bin so it needs to represent the current release. I removed bin/ from shared_dirs
I've started a rails project using rails new with --webpack=react.
I generated a new controller updated my PostgreSQL password in the database.yml.
Up to this point, everything works fine. At this point all I'm trying to do is get react to render the default hello_react.jsx file that was generated as an example by rails.
When I put <%= javascript_pack_tag 'hello_react' %> in my view and run the server I get the following error:
Webpacker::Manifest::MissingEntryError in Home#index Showing
G:/../../../myGroceryList/app/views/home/index.html.erb where line #1
raised:
Webpacker can't find hello_react.js in
G:/../../../myGroceryList/public/packs/manifest.json. Possible causes:
You want to set webpacker.yml value of compile to true for your
environment unless you are using the webpack -w or the
webpack-dev-server. webpack has not yet re-run to reflect updates. You
have misconfigured Webpacker's config/webpacker.yml file. Your webpack
configuration is not creating a manifest. Your manifest contains: { }
I have pushed the project up to GitHub. Any thought on what is going wrong and how to fix this error?
RESOLVED: Resolution in comments
Jonny B,
I encountered the same issue. I was able to determine that I needed to add '.jsx' to my webpacker.yml.
extensions:
- .js
+ - .jsx
- .sass
- .scss
- .css
I also found that webpacker:compile was not being run on page refresh or when files were changed. I needed to run bundle exec rake assets:precompile (or bundle exec rake webpacker:compile) manually after each change to be able to reload and see the changes.
I am running the application via Apache+Mod_Passenger rather than using rails s (I have too many apps in development at the same time to keep starting and stopping a server on the command line). It seems like this doesn't work well with Webpacker's compile-on-demand functionality. Starting a server with rails s will allow me to hit the app on localhost:3000, but the react app doesn't render correctly. After hitting the page via the Puma server on 3000, I can now see the compiled assets working in my Apache/Passenger instance. So, the on-demand compiling seems to only work properly when running in a server started on the command line (rails s) ...which doesn't render correctly. :-/
The other option (better than running 2 servers) is to compile on the command line using bundle exec rake assets:precompile or bundle exec rake webpacker:compile whenever you make a change. Still a PITA, but at least it works ...for now. If I find a better solution, I'll update the answer.
UPDATE
After a lot of playing around, installing different version of NodeJS, Ruby, rbenv, nvm, etc., I was able to determine that the NODE_ENV wasn't being set for the Apache/Passenger environment. Using Rbenv, I was able to add an .rbenv-vars file in my app root containing:
NODE_ENV=development
RACK_ENV=development
RAILS_ENV=development
Now, Webpacker (and NodeJS) see that I am running in development rather than production, and the compile-on-demand is working.
RESOLUTION: As best I can tell this error fires when your public/packs folder is missing the Manifest file or is missing all together. What was happening in my case was Webpackers compilation step was silently failing and not creating the public/packs folder. I checked in a fix to the webpacker gem for this. You can see that fix and conversation here.
if this is the root cause then you can fix with either of these depending on how you prefer to install node packages
yarn install
or
npm install
I'm developing a Rails 4.1 application. I use ckeditor
(https://github.com/galetahub/ckeditor), and I'm using some extraplugin
(image2, which also uses widget), stored in app/assets/ckeditor/plugins
directory. I used it with f.cktext_area :extraPlugins => 'image2'. It
works well in development and also in production environment.
Now I decided to add one more extra plugin (syntaxhighlight), stored and
used in the same way (stored in app/assets/ckeditor/plugins , called
with :extraPlugins => 'image2,syntaxhighlight'). In development
environment it works perfectly, but in production ckeditor cannot load
syntaxhighlight plugin, because it try to load not the hashed version of it:
uncaught exception: [CKEDITOR.resourceManager.load] Resource name
"syntaxhighlight" was not found at
"/assets/ckeditor/plugins/syntaxhighlight/plugin.js"
I run "rake assets:precompile" many times, it generated the hashed
version of plugins
(/assets/ckeditor/plugins/syntaxhighlight/plugin-a9ce9661bf06ef29e7ac40baac50c044.js).
But none of the working other (old) extraplugins do not have simple
plugin.js in the public directory, and they work.
Any idea how to make work this new extra plugin?
I had the same problem. To solve this, run:
rake tmp:cache:clear
and after assets:precompile again.
Just to understand what happened: ckeditor gem generate a mapping file (override.js), and it maps the simple and the hashed version of js files. If you insert a new extraplugin, it will not regenerated with assets:precompile, you have to clear the cache to force it.