Add Hotwire to existing Rails 6.1 app using sprockets - ruby-on-rails

I'm trying to upgrade an existing Rails 6.1 with sprockets app to use stimulus. I installed
gem 'importmap-rails'
gem 'hotwire-rails'
The javascript_importmap_tags causes this error in Firefox Developer Tools:
Uncaught TypeError: Error resolving module specifier “application”. Relative module specifiers must start with “./”, “../” or “/”.
Should this work alongside sprockets?
I have importmap-rails (0.7.6), stimulus-rails (0.4.2)

Error can be safely ignored I believe.
Update: I can confirm that this error can safely be ignored, it doesn't cause any issues. Obviously this is not the ideal "solution", hence the downvote I guess, so if anyone knows a better answer and posts it that will be great and I will mark it as the accepted answer.

Related

Type application/netcdf is already registered as a variant of application/netcdf

I have a standard rails app on rails 7 and I'm seeing this warning but not even sure where it comes from, any idea?
Type application/netcdf is already registered as a variant of application/netcdf.
There is currently an issue in the mime-types-data gem related to a duplicate definition of this mime type. If you look inside your Gemfile.lock file, you’ll probably find this gem used as a dependency. Luckily, this is just a warning without any consequences. Possible solutions are discussed in the issue.

Deprecation warning when using Compass Rails

I am using the Compass gem for Rails. After installing it, I've used some mixins that come with Compass. I am getting a deprecation warning in the console:
DEPRECATION WARNING on line 87 of /usr/local/rvm/gems/ruby-2.3.0/gems/compass-core-1.0.3/stylesheets/compass/css3/_deprecated-support.scss: #{} interpolation near operators will be simplified
in a future version of Sass. To preserve the current behavior, use quotes:
unquote('"$moz-"#{$experimental-support-for-mozilla} "$webkit-"#{$experimental-support-for-webkit} "$opera-"#{$experimental-support-for-opera} "$microsoft-"#{$experimental-support-for-microsoft} "$khtml-"#{$experimental-support-for-khtml}')
You can use the sass-convert command to automatically fix most cases.
I am having trouble finding a fix for this online. What does this warning mean and what can I do to fix it?
Apparently this is a bug in the gem. Workaround until fix is pushed to gem here: https://github.com/Compass/compass/pull/2088

aws-s3 gem unless defined? ##{:instance_writer=>true}

I am trying to integrate the aws-s3 gem with the latest version of Rails (4.1.0), and when starting the server I receive this error:
aws-s3-0.6.3/lib/aws/s3/extensions.rb:223:in `class_eval': ///.rvm/gems/ruby-1.9.3-p385/gems/aws-s3-0.6.3/lib/aws/s3/extensions.rb:223: syntax error, unexpected $undefined (SyntaxError) unless defined? ##{:instance_writer=>true}
Has anyone got any ideas?
The bulk of the gem has not been updated for over two years so I am thinking that it may finally be out of date.
In Rails 4.1 the bug is happening because cattr_attribute was removed from Module.
A short look at the issues in github: they say that the project has been abandoned.
This pull request was to fix the issue:
https://github.com/marcel/aws-s3/pull/95
You may want to use one of forks like https://github.com/bartoszkopinski/aws-s3, that fixes the issue, or change the gem to the https://github.com/aws/aws-sdk-ruby.

JSON error with coffeescript & Rails asset pipeline

I am using Rails 3.2.14 without issue...
I have recently renamed application.js to application.js.coffee and am now getting a JSON error.
JSON::GeneratorError
only generation of JSON objects or arrays allowed
(in /.../app/assets/javascripts/application.js.coffee)
Even when I delete all the contents of application.js.coffee I still get the error.
When I try to view it directly (http://localhost:3000/assets/application.js), its the same issue:
throw Error("JSON::GeneratorError: only generation of JSON objects or arrays allowed\n (in /.../app/assets/javascripts/application.js.coffee)")
I have combed my app for any potential issues but everything looks pretty standard.
I had a similar problem (Rails 4 asset pipeline throws "only generation of JSON objects or arrays allowed"), which had nothing to do with application.js. The multi_json gem got updated from 1.7.8 to 1.7.9, and broke my app. Any change to the cofeescript-files resulted in this "only generation of JSON objects or arrays allowed" error.
I explicitly put the multi_json gem in my Gemfile, fixed to version 1.7.8. In solved the problem for me.
I have the save issue not in a Rails project, but a ruby project using sprockets.
I have not finally determined the problem, but it seems to be related to execjs and the Javascript runtime used.
You can try to add
gem 'therubyracer'
to your Gemfile. This installs the v8 engine, which solved the problem for me.

Rails ckeditor Invalid CSS after "*": expected "{", was "html .cke_uicol..."

I'm updating an app to rails 3.1 and I'm getting this error when precompiling my assets, I've updated ckeditor to 4.0.2 because according to this Github Issue that will fix it but the error is still there. Do I have to do something after I update the gem?
Here's the full error:
Invalid CSS after "*": expected "{", was "html .cke_uicol..."
"html" may only be used at the beginning of a compound selector.
(in /home/stanwinston/stanwinston/app/assets/javascripts/ckeditor/_source/plugins/uicolor/yui/assets/yui.css)
Thank you in advanced!
Well, I am going to catch some flak for this but, after trying to upgrade and blah blah blah 3 hours, here was how I fixed it:
Due to the complexity of my app, and the requirement to support IE 8, I was unable to readily change the rails or ckeditor version. What I did instead was to fix the css included in the gem:
/opt/boxen/rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/ckeditor-3.7.1/vendor/assets/javascripts/ckeditor/plugins/uicolor/yui/assets/yui.css
There is a "*html" where you need a "* html", note the space.
Here are some related posts about the issue:
http://dev.ckeditor.com/ticket/9411 and https://github.com/galetahub/ckeditor/issues/188
Then I precompiled my assets locally, so that the asset compilation happened on my machine with the patched gem. I am not a fan of this method, but my client is not a fan of broken web forms, or longer hours spent updating libraries without adding any new features.
There is no point in submitting a pull request against the gem, since it is code from a 3rd party of a 3rd party and the gem has long since switched to rails 4 support.
Feel free to tell me I am wrong for X reason below.
I'm also stumble upon the same situation but update my Rails version to 3.2+ solve the problem

Resources