I've installed the Masonry gem both using my gemfile:
gem 'masonry-rails'
...as well as from the console:
$ gem install masonry-rails
Successfully installed masonry-rails-0.2.4
Parsing documentation for masonry-rails-0.2.4
Installing ri documentation for masonry-rails-0.2.4
Done installing documentation for masonry-rails after 1 seconds
1 gem installed
I've restarted my app, but when I call:
//= require masonry/masonry
in my application.js, I see the error:
couldn't find file 'masonry/masonry' with type 'application/javascript'
...any thought on why this might occur? I've used the CDN successfully, but wanted to switch over to the gem. I've also tried requiring masonry rather than masonry/masonry with no avail.
You should use
//= require masonry/masonry
if you don't use jQuery
Otherwise you should include jquery.masonry
//= require masonry/jquery.masonry
instead
Are you sure that you restarted your server?
If so, I advise you to perform manual installation by uploading masonry file in the vendors folder and manually writing the code to the product.js.
Related
I just upgraded our Rails app from 4.2.5 to 5.0.1
The rails server boots up fine but when I try to load a page I'm now getting the error:
Sprockets::FileNotFound - couldn't find file 'jquery-ui/autocomplete' with type 'application/javascript'
When I run bundle I can see
Using jquery-rails 4.2.2
Using jquery-ui-rails 6.0.1
change the line in application.js
from
//= require jquery-ui/autocomplete
to
//= require jquery-ui/widgets/autocomplete
Seems the file paths have changed. According to the gem readme:
Warning:
Due to directory structure changes between jQuery UI 1.10, 1.11, and 1.12, if you use version is lower than 6.0, you will have to use a different naming for the files to require, please check following links for more information: for 5.0 users, for 4.2 users.
My case was exceptionally weird. When I set up my old legacy app in Ubuntu 20 it worked fine until I rebooted my laptop. After that it displayed the error under question. I checked that I use correct RVM gemset with correct ruby version, gems were bundled as they should have.
When I changed the
//= require jquery-ui/autocomplete
to
//= require jquery-ui/widgets/autocomplete
this line passed and worked fine, but next ones starting causing problems.
Eventually I had to change all the following lines:
//= require jquery-ui/widgets/autocomplete
//= require jquery-ui/widgets/datepicker
//= require jquery-ui/widgets/droppable
EXCEPT THIS:
//= require jquery-ui/effect and I have no idea why this single line works while others don't :/
I am using the fullcalendar rails gem. I just downloaded the zip file for the calendar which contains the js and css files for the fullcalendar plugin. For all the tutorials on the fullcalendar gem I have not seen anyone doenload the zip file and use these files in their code (they use the CDN links but those don't appear to be working) where is the best folder to place these zipped assets into so that I can get the desired results on my calendar?
If you use the gem you do not need download any file.
You have to:
install gem
add in the application.js file the instruction //= require fullcalendar
And to can use it.
Read the README of the gem https://github.com/bokmann/fullcalendar-rails
Because you also need moment.js
Don't install from the zip file.
Follow the instructions at https://github.com/bokmann/fullcalendar-rails#installation for installation; you will have an easy time managing the dependencies.
The steps as specified there are:
Add gem 'fullcalendar-rails' to Gemfile
Add gem 'momentjs-rails' to Gemfile if you want to use 2.1.1.0 or higher version of fullcalendar-rails gem.
Run bundle install to install the gems.
Add //= require fullcalendar (and //= require moment) in application.js
Add *= require full calendar in application.css
I installed the Redactor gem, but after some time I decided that this gem doesn't suit my needs. I removed it from Gemfile, and also removed all of the gem's files (I suppose) in all app folders.
When I try to deploy app, the server fails to start with this error:
uninitialized constant Redactor Rails
It points to the folder which I actually removed (in models). Each time it is created while I'm pushing the app to the server (with git).
How can I completely remove ALL the files that the gem generated?
You sure did
gem uninstall redactor-rails
Remove in your application.js
//= require redactor-rails
also in your application.css
*= require redactor-rails
The gem also generated in
app/uploaders/redactor_rails_document_uploader.rb
app/models/redactor_rails/document.rb
I am using Ruby on Rails 4.
I am trying to
require 'rest-client'
in my controller so that I can parse the login information I am getting from a form and send it to an API.
I can verify that the gem is installed and is also in my Gemfile on the application root.
However, it is still throwing the "cannot load such file -- rest-client " when I try to require the file in my controller.
I have googled the error and most of the answers I saw were either the gem wasn't installed, wasn't in the Gemfile, or a combination of both those. Neither is the situation here.
Is my controller unable to access the rest-client gem for some reason? I have to use rest-client because it is required in the API.
This is the line I used to install the gem:
gem install rest-client
This is the homepage of the gem: https://github.com/archiloque/rest-client
Which just redirects you to https://github.com/rest-client/rest-client
I should also note that it works fine when I wasn't using the code in a Rails project but just running the commands in the Terminal.
Assuming you're using https://github.com/rest-client/rest-client (since you didn't specify), your require line should be
require 'rest-client'
according to the README. Also, make sure you restart your rails server after adding the gem to your Gemfile and running bundle.
Run the following command in your terminal:
gem install rest-client
and use require 'rest-client'. No need to change to rest_client.
in my case, none of the solutions in this thread worked
what did work, was to add the gem directly in the Gemfile:
gem 'rest-client'
after closing the rails server, exiting rails console and running bundle install,
I opened again the rails console and this time require 'rest-client' worked flawlessly
For me it was an issue with bundle (which I thought I had installed). Spoiler alert, I didn't, and this is how I fixed it. I'm on a Mac running OS X Yosemite and my terminal version is Darwin Kernel Version 14.3.0:
cd
gem install bundler
or
cd
sudo gem install bundler
If you get something along the lines of the following error:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
Finally, change your require line from:
require 'rest-client'
to
require 'rest_client'
Then run your code!
First ensure you have installed gem 'rest-client', ~> 1.8.0 on your gem file. Run bundle install and then require 'rest_client'. This worked for me.
Try require 'rest_client', instead of require 'rest-client'
I tried to use the foot-rails gem to install flot but was unsuccessful.
I added gem "flot-rails" to my gemfile and executed bundle install
I then added
//= require jquery.flot
//= require jquery.flot.resize
to my /app/assets/javascripts/application.js file
I verified that the gem installed properly (gem show flot-rails) and found that the javascripts were all in the vendor directory of the gem but my app reports
couldn't find file 'jquery.flot'
(in ...path/app/assets/javascripts/application.js:12)
I chose to just install the files manually into my assets directory but I'd like to know what's wrong with my sprockets.
Why ca't Sprockets resolve the references?
Well, don't I feel stupid.
I needed to restart the web server after bundle install