My RoR application falls down with the following error:
ActionView::Template::Error (undefined method `attributes_for' for
Sprockets::CachedEnvironment:0x00000005baf3d8
As I found out this error happens when the javascript in the html.erb template is rendering. Also I noticed that in all templates where it happens exists tinyMCE initialization command.
I suppose, that it is something environment specific, because at my development machine it works fine and at production server it also works fine. I began to receive this message when I decided to install 2nd production server for testing purposes. I installed CentOS 6 + rvm + ruby 2.2.0 (the same as at 1st production server). Maybe I missed to install something?
As the problem is related to tinymce and sprockets I am guessing that you are using tinymce-rails GEM.
The tinymce-rails GEM does not work fine with sprockets >= 3. It is using some API that was removed in version 3.
If you still want to use tinymce-rails GEM, please lock sprockets to ~> 2. This has solved problem for me.
The perfect solution would be to make a pull request for tinymce-rails to make it work with the latest sprockets, but that's whole nother story.
Related
I have an old Rails app that I'm trying to upgrade to Rails 7. Somewhere in the upgrade process I broke the asset pipeline. When I make updates to a javascript file, the changes aren't visible unless I run rails assets:precompile and restart the server.
When I do run rails assets:precompile, I get a bunch of compiled JS and CSS assets in my public/assets folder. This seems like an outdated version of the asset pipeline process.
This project is a personal project that I've had lying around for years and it spans Rails versions from 4 to 7. It's never had a user base, it's just an idea that I go back and work on from time to time. So it's possible I have an old version of the assets pipeline running.
I created a new Rails 7 project from scratch and it works as expected. I've been trying to make the new project as close to my existing project as I can to see where my current project is breaking, but that is becoming extremely difficult and not yielding any results yet.
I'm sure I must have some old configuration still in place but I have no idea where to look. I can't remember ever having this problem before. I would love any suggestions on where to look for differences between the old broken application and the new one that works.
So this is really unsatisfying, but what finally resolved this issue was that I removed the bootsnap gem. I don't know what was happening or why, but after removing this gem, it behaved normally.
After updating to latest stable version of library ngx-masonry 14.0.0 tests failed. They had release yesterday (24.10.2022.) and here is the link to their changelog: https://github.com/wynfred/ngx-masonry/blob/master/CHANGELOG.md
Basically they added Ivy build since they were using ViewEngine on older versions. I suppose that this error is connected to that migration to newer Angular compiler. On project we use Angular version 14.
After running npm i ngx-masonry#14.0.0 update was successful without any vulnerabilities.
In order for me to test it, I run ng test for my Angular application to make sure everything is fine. The failing test is basically the basic one which tests if the component is getting created. The following error was thrown in couple of components that rely on ngx-masonry library: ReferenceError: require is not defined
Since this is quite fresh issue (<24hrs old) probably more developers will run into it when they upgrade version to 14.
Link to the issue opened right now on their GitHub repo: https://github.com/wynfred/ngx-masonry/issues/98
Maybe we are missing something or this could be solved easily. :)
The owner of the library have just released 14.0.1 version which contains the fix. After you run npm i ngx-masonry#14.0.1 everything should be fine. Tests are passing as expected and app compiles successfully.
The project I am working on, works in the development environment. But when I deploy it live and navigate to the site, I only see blank screen.
I get the following errors in the console (from both development and production environment)
The same error exists in the development and production environments. The different is, I can navigate through the site pages in the development environment. But I only see a blank screen in the production environment.
I tried to update my jQuery to the latest version using the following command:
meteor npm install --save jquery meteor-node-stubs
But I still get the same error.
What am I doing wrong here?
This issue cost me some time to work out. Basically you need to find a sweet spot for jquery.
Meteor loads jquery by default, and in .meteor/packages I have jquery#1.11.10, which is probably what Meteor puts in for you.
You will also need to load a version somewhere in between that works. For me this command did the trick:
meteor npm install jquery#2.2.4
Cheers
So, the app was working great locally until I precompiled the assets. When deploying to heroku I did assets precompile and then deployed and it worked fine at heroku, but now it seems javascript got broken.
Any suggestions on how to solve it? Should I delete the files at public folder or use some configuration?
Thanks in advance
UPDATE
I get one of this for each asset file I load in development mode, is it normal?
Started GET "/assets/home.js?body=1" for 127.0.0.1 at 2012-06-15 19:16:48 +0100
Served asset /home.js - 304 Not Modified (0ms)
This is odd. I'm using twitter bootstrap and now to test if javascript is messed up I added a tooltip html example to check if it is also crashed and it actually worked.
But my dropdown at menu bar does not work. How strange is this?
Finally I solved the problem.
Just changed in config/environments/development.rb
config.assets.debug = true
to
config.assets.debug = false
And now javascript works as expected
UPDATE
Now when I have this problem I actually run rake assets:clean and clean the browser cache. This will make your app work as it used to work in development work.
If you want to have a better process, you could instead create a new branch where you run precompile and keep your master branch clean.
Other alternative is to run precompile on heroku so you don't have to do it locally. I haven't tried it yet but there is a 'beta' feature you have to enable so this can work properly in all apps. You can read about it here
I am currently in a web development class and we are using Ruby on Rails.
I am using Ruby v1.9.2 and Rails v3.1.1.
My initial problem started when I tried to execute 'rails server'.
I would get the following error:
C:\Sites\rorProjects\basicRoRProject>rails server
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/execjs-1.2.13/lib/execjs/runtimes.rb:47:in `autodetect': Could not find a JavaScript runtime.
See https://github.com/sstephenson/execjs for a list of available runtimes.(ExecJS::RuntimeUnavailable)
I have done some reading and the general consensus is to install the gems 'execjs' and 'therubyracer'. 'execjs' installed just fine, however when I tried to install 'therubyracer' I got the following error:
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing therubyracer: ERROR: Failed to build gem native extension.
C:/RailsInstaller/Ruby1.9.2/bin/ruby.exe extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers.
Check the mkmf.log file for more details.
You may need configuration options.
I then did some more reading and found a couple of people said to check that they had the gem 'libv8', which was required for 'therubyracer'. I did that and discovered that I didn't have it, so I then went to install that and got the same error that I did for 'therubyracer'.
I'm at a loss to think of anything else to do. Any help would be greatly appreciated.
Thanks guys!
THIS PROBLEM HAS BEEN SOLVED.
So, with the help of one of my classmates who had a similar problem, I installed Node.js using the Windows installer (this gave me a JavaScript run-time environment). I then added it to the path in the local variables.
So, with the help of one of my classmates who had a similar problem, I installed Node.js using the Windows installer. I then added it to the path in the local variables.