What is the purpose of the gem 'sass-rails' that is included by default in the :assets group of a new rails app ?
If I comment out that line I can still use .css.scss files without a problem.
You need it for sass/scss files. Clear your browser cache, clear rails cache (Rails.cache.clear in console), comment out the line, uninstall the gem (all versions), then restart your server. You'll get the following error:
no such file to load -- sass
Uncomment the line for the sass-rails gem, reinstall the gem and restart your server to make it work again.
Related
In my project with content_tag_for I had an error:
The content_tag_for method has been removed from Rails. To continue
using it, add the record_tag_helper gem to your Gemfile: gem
'record_tag_helper', '~> 1.0'
So, I added this gem to my Gemfile. $ bundle install returns:
Using record_tag_helper 1.0.0
I have restarted server, cleared Rails cache and so on, but I still have the same error, that content_tag_for method has been removed from Rails. I just have no more ideas why it doesn't work.
Share your ideas, please.
Looking at the Github page, the gem has not been updated in 2 years. Also the last update contains the message 'Prep for Rails 5'. I'm assuming that this gem isn't compatible with Rails 5.
I have added "require 'record_tag_helper'" to my application.rb file and now it works.
I am developing a gem meant to be used with Rails projects and want to try it out locally with another Rails app of mine.
I built the gem with bundle exec rake release which put a .gem file in the /pkg directory.
Then, in my Rails app, I added the following to my gemfile
gem 'mygem', '0.1.1', path: '/Users/me/projects/mygem/ruby/pkg'
I then ran bundle install which said it installed the gem. When I do this, it removes the gem from the path. IDK where it went.
When I start the Rails app, it's like the gem isn't included at all.
Interestingly, if I add a version that doesn't even exist, it still says bundle install works fine. (Example: gem 'mygem', '0.1.2345', path: '/Users/me/projects/mygem/ruby/pkg')
What am I supposed to do to try out my Gem locally with a Rails app?
This question is different from How can I specify a local gem in my Gemfile? because I explicitly tell bundle in my Gemfile to use the local gem, with the path given, and it still doesn't work. When I run bundle install, it says
Using mygem 0.1.1 from source at /Users/me/projects/mygem/pkg
So you'd think it works right, but it still doesn't.
Interestly, if I try it with a version number that doesn't exist, like mygem 1.2.3, it still runs bundle install successfully, which is really weird and seems like a bug:
Using mygem 1.2.3 (was 0.1.1) from source at /Users/me/projects/mygem/pkg
I prefer to use the following when working on a local gem side-by-side with a Rails project:
gem 'foo',
:git => '/path/to/local/git/repo',
:branch => 'my-fancy-feature-branch'
I have an existing Rails 3.2.14 application that I am trying to add zurb-foundation to. I have added the zurb-foundation gem and run the installation generator.
My problem is that, whenever I try to load a page, I get this error:
couldn't find file 'foundation'
when Sprockets hits the
//= require foundation
line in application.js
The problem appears to be that the directory with the assets from the zurb-foundation gem are not being added to the load path. In contrast, I have an application that I generated more recently, including zurb-foundation from the beginning, and #asset_paths.asset_environment.paths includes the following
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-rails-3.0.4/vendor/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/zurb-foundation-4.3.0/scss",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/zurb-foundation-4.3.0/js"
which are not included in the asset load path in the app I am updating. Instead, I am getting (with p #asset_paths.asset_environment.paths in the better_errors diagnostic window)
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-ui-rails-4.0.4/app/assets/images",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-ui-rails-4.0.4/app/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-ui-rails-4.0.4/app/assets/stylesheets",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-rails-3.0.4/vendor/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/assets/javascripts"
interestingly, if I run the console in development mode and look at Rails.application.config.assets.path, it includes:
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-ui-rails-4.0.4/app/assets/images",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-ui-rails-4.0.4/app/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-ui-rails-4.0.4/app/assets/stylesheets",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-rails-3.0.4/vendor/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/zurb-foundation-4.3.1/scss",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/zurb-foundation-4.3.1/js"
and that DOES include the zurb-foundation asset paths.
I have included gem 'zurb-foundation' in the assets group, in the development group, and outside any group. I am using zurb-foundation-4.3.1 in the new app.
My Gemfile assets group is:
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
gem 'compass-rails'
gem 'zurb-foundation'
end
This problem seems similar to Sprockets::FileNotFound with ZURB Foundation, although Jurriaan did not mention the asset load path.
Any idea what I could be missing?
Thanks!
Have you tried restarting the webserver?
Update:
You said it runs fine in development, Have you tried to rake assets:clean and rake assets:precompile?
It was a problem with a gem that was preventing foundation's entries being added to the load_path. The gem involved was mongomapper-versioned.
By not loading that gem, the problem resolved. By adding the gem back, the problem recurs.
That gem has not had any activity for two years. I guess it's time to find something else.
I have installed Paperclip but I have error when I try to run
rake db:migrate
after
rails generate paperclip asset photo
I get
cannot load such file -- paperclip/tasks/attachments
What is wrong? This folder exists with that file.
Try using:
bundle exec rake db:migrate
When I tried downloading it as a plugin (rails plugin install ... ), I saw the same problem. I deleted the plugins from vendor/plugins directory and then added the paperclip gem to gemfile (gem "paperclip", "~> 3.0") and everything now works. You may want to give it a try.
To make sure paperclip is loaded and the version which supports attachments, do
bundle show paperclip
Open the gem in text editor and check if paperclip/tasks/attachments.rb is present. If no, then the version of the gem needs to be upgraded or uninstall all paperclip gem versions and do a fresh install. paperclip-3.5.0 works.
If the version is correct and if it still throws error, include
require 'paperclip'
in your boot.rb.
This forces rails to include the gem at boot time.
I have strange old buggy project on Rails 2.
It have gem's dependencies in config/environment.rb like
config.gem "andand"
config.gem "json"
config.gem "chronic"
config.gem "mini_fb"
all those gems are located in vendor/gems/
andand-1.3.3/
chronic-0.6.7/
json-1.7.3/
mini_fb-1.1.7/
rbet-1.0.3/
redis-3.0.1/
responsys_client-0.0.1/
but when i start unicorn server with this app it always complain that it can't find this gems. Why?
UPDATE
After building and installing gem from vendor/gems rails still complain about it.
I have tweake mini_fb gem into custom mini_fb_custom gem. Changed all references in gemspec and other files from mini_fb to mini_fb_my, installed it and it is shown in gem list as mini_fb_my. But it fails to load from config/environment.rb and complains that
Missing these required gems:
mini_fb_my >= 0
maybe i should rename lib/mini_fb.rb to lib/mini_fb_my.rb
i'll check it.
UPDATE 2
Yes, renaming files rocks!
You still need to install them from those folders, or unicorn will not know where to look for them.
Just install the gems from that directory and unicorn should pick them up.
UPDATE
You can install your gems locally with this command
gem install --local vendor/gems/gem/gem-name.gem
On more recent versions of rails you just specify path on the Gemfile
gem "gem-name", path: "path/to/gem"
My advice: replace the obsolete gem configuration with bundler (it works fine with rails 2, there should be a tutorial for rails 2 available on their website).
Configuration through gem command, freezing gems, etc. is just pain in the a** and it seemed kinda buggy to me when I'd used it (long time ago).