asset pipeline not generating application.js application.css - ruby-on-rails-3

not sure what I'm doing wrong. but I get:
GET http://localhost:3001/assets/application.css 404 (Not Found)
Here is my config:
gem 'rails', '3.1.0.rc3'
gem 'rake', '0.9.2'
group :assets do
gem 'sass'
gem 'coffee-script'
gem 'uglifier'
gem 'sprockets'
end
in application.rb:
config.assets.enabled = true
in app/assets/javascripts/application.js:
//= require jquery
//= require jquery_ujs
//= require_tree .
similarly for app/assets/stylesheets/application.css
Why aren't the /assets/application.[css|js] generated/accessible? do I need to run something manually? also is sprockets needed or it's part of rails now?

It's not a specific answer to your problem, but it might solve it: I ran into a lot of issues which were fixed by switching to rc5 - I notice in your gemfile you're using rc3. I was getting a lot of hiccups like this when I was on rc4.
You don't need to add sprockets in your gemfile anymore once you do this either. Also, you don't mention it but do you have gem 'jquery-rails' in your gemfile too?

As Richard pointed out, moving to rc5 helped:
gem 'rails', '3.1.0.rc5'
but I was still getting "stack level too deep" issues which I finally figured out was due to my version of sprockets (beta.13) so I added a previous version the gem file:
gem 'sprockets', '2.0.0.beta.12'
and things are working fine :)

I was running into this problem as well and it took me a lot of tinkering to get it back to a working state. What I finally ended up doing that worked is:
Adding the following line to application.rb:
Bundler.require *Rails.groups(:assets) if defined?(Bundler)
Changing up my Gemfile so that I had the following defined:
group :assets do
gem 'sass-rails', "~> 3.1.0.rc"
gem 'coffee-rails', "~> 3.1.0.rc"
gem 'uglifier'
end
Bundle install, relaunch my server and voila, I have css and js again.

Related

Could not find gem 'sprockets (= 2.2.2.backport2) ruby' in the gems available on this machine

I have a problem with my gemset.
I created a new one after a fresh install on my computer, just one step after cloning the repo.
Running bundle install but I get this error
Could not find gem 'sprockets (= 2.2.2.backport2) ruby' in the gems available on this machine
I'm using Rails 3.2.11 and ruby 2.1
I have followed the suggestion of the bootstrap-sass Readme
But it doesn't work
Here is the part of my Gemfile with assets group
group :assets do
gem 'sass-rails', " ~> 3.2.3"
gem 'compass-rails'
gem 'sprockets-rails', '=2.0.0.backport1'
gem 'sprockets', '=2.2.2.backport2'
gem 'bootstrap-sass', '~> 3.1.1'
gem 'coffee-rails', "~> 3.2.1"
gem 'uglifier', '>=1.0.3'
gem 'eco'
gem 'i18n-js'
end
The project works on other machines. What can I do?
UPDATING THE QUESTION
Now I have the same problem but with rbenv, and I don't know how to solve it because rbenv doesn't have gemsets!
I had the same issue yesterday. A colleague of mine came across a Twitter conversation which points to a new fork of Sprockets with a 2.2.2.backport2-type tag.
You can get it on GitHub or add it to your Gemfile:
gem 'sprockets', github: 'tessi/sprockets', branch: '2_2_2_backport2'
I have solved the problem following these steps:
Change the gemfile replacing the sass-rails gem with this one: gem 'sass-rails', github: 'guilleiguaran/sass-rails', branch: 'backport'
Create and use a new empty Gemset
Go here and download this gem sprockets 2.2.2 backport2
Copy the downloaded gem in vendor/cache section
run bundle install
This should solve the problem related to this gem sprockets (= 2.2.2.backport2) ruby because it will be installed by the downloaded one.
Not the best, but I found the gem and cached it (put it in vendor/cache) based on this: https://github.com/aliw77/sprockets-2.2.2.backport2. I have a feeling there's another solution, still looking for it.

Bundled versions of rspec and cucumber gems in a new rails 3.2 app

I am experiencing a problem with the cucumber and rspec gems bundled in a rails app.
This is what my Gemfile looks like in a new Rails 3.2.11 application with RSpec support added:
source 'https://rubygems.org'
gem 'rails', '3.2.11'
gem 'sqlite3'
gem 'jquery-rails'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
group :test do
gem 'rspec-rails'
end
After running bundle, Gemfile.lock reports that rspec 2.12.2 is being used (the latest version of the gem, as of this writing).
But I also want to use cucumber, so I run bundle update after modifying Gemfile like so:
group :test do
gem 'rspec-rails'
gem 'cucumber-rails'
end
To my surprise, the bundled rspec is now version 2.0.1, definitely NOT cool.
In fact, this was causing all kinds of errors when running specs, and it took me a while to figure out that they were old rspec errors, fixed long ago.
I can force bundler to use the latest gem:
group :test do
gem 'rspec-rails', '>= 2.12.0'
gem 'cucumber-rails'
end
but I am unhappy, because I do not understand:
if I did something wrong to begin with
if the fix I applied is going to cause other problems down the road
if there was a way to predict this behavior
Any insights?
According to https://github.com/cucumber/cucumber-rails/blob/master/cucumber-rails.gemspec#L22, cucumber-rails depends on 'rspec-rails', '~> 2.10.1' (which means >= 2.10.1 and < 2.11). If any other upstream dependency depends on a version of rspec < 2.10.1 or >= 2.11, bundler should raise an error, so I can't understand how this happened.
As an aside, you should include rspec-rails in both the :development and :test groups (per https://github.com/rspec/rspec-rails#configure).

Can't access to bootstrap methods when including bootstrap via application.js

First of all, my gemfile
gem 'mysql2'
gem 'json'
gem 'jquery-rails'
gem 'dynamic_form'
gem 'haml-rails'
gem 'geocoder'
gem 'delayed_job_active_record'
gem 'daemons'
gem 'pry'
gem 'debugger'
gem 'unicorn'
gem 'rest-client'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'anjlab-bootstrap-rails', '>= 2.1', :require => 'bootstrap-rails'
gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
When I have this manifest in my application.js
//= require jquery
//= require jquery_ujs
//= require twitter/bootstrap
//= require_tree .
if I declare an input with the proper attributes, like this
<input autocomplete="off" data-provide="typeahead" data-source="['Alicante','Albacete']" size="30" type="text">
it works like magic, but I can't do this in my own js
$('#my_input').typeahead()
// => TypeError: Object [object Object] has no method 'typeahead'
However, if I remove bootstrap from the manifest and I include it my layout explicitly
= javascript_include_tag "application", "bootstrap.min"
both ways work.
Can anyone explain me why? Maybe the uglifier of the asset pipeline is namespacing bootstrap functions? How fix it?
Use //= require twitter/bootstrap
https://github.com/anjlab/bootstrap-rails
Edit:
Which gem are you using? twitter-bootstrap-rails, bootstrap-rails or something else?
if using twitter-bootstrap-rails then did you already call rails generate bootstrap:install to set it up?
Does changing the order makes a difference? Try it like this
//= require jquery_ujs
//= require jquery
//= require twitter/bootstrap
//= require_tree .
I've just solved the problem.
It seems that this behavior happens when Bootstrap is being loaded twice (no idea why).
I can't say why that happened, maybe because I tried a couple gems of Bootstrap, but there was a problem with my auto-compiled assets in /public that are generated in production environment.
I run rake assets:clear (task provided by github.com/anjlab/bootstrap-rails) y all works fine again.

spree install undefined method mass_assignment_sanitizer

I took a look about this problem within the list of question but nothing helped.
This is my first question in stackoverflow so please accept my apologies in case I do something wrong. Also I still have a lot of english to improve.
I'm installing Spree following the github instructions
$ gem install spree
$ rails new my_store
$ spree install my_store
when I get this message
...
Admin Password [spree123]
gemfile spree
gemfile spree_usa_epay
gemfile spree_skrill
run bundle install from "./my_store"
git://github.com/spree/spree_usa_epay.git (at 0cb57b4) is not checked out. Please run `bundle install`
precompiling assets
git://github.com/spree/spree_usa_epay.git (at 0cb57b4) is not checked out. Please run `bundle install`
...
Well, as the guide suggests, in case of circular dependency issues do:
$ gem install spree_cmd
$spree install my_store -A
gemfile spree
gemfile spree_usa_epay
gemfile spree_skrill
run bundle install from "./my_store"
git://github.com/spree/spree_usa_epay.git (at 0cb57b4) is not checked out. Please run `bundle install`
precompiling assets
git://github.com/spree/spree_usa_epay.git (at 0cb57b4) is not checked out. Please run `bundle install`
I changed directory to the app and run the command:
$cd my_store
$bundle install
and I get the following error
Bundler could not find compatible versions for gem "rails":
In Gemfile:
spree_usa_epay (>= 0) ruby depends on
rails (<= 3.1.3, >= 3.1.1) ruby
rails (3.2.1)
after this I changed the gem file to work with rails 3.1.3 and coffeescript gems and repeat the whole process again and I get this.
Users/Snake/.rvm/gems/ruby-1.9.3-p0/gems/activerecord- 3.1.3/lib/active_record/base.rb:1088:in `method_missing': undefined method `mass_assignment_sanitizer=' for ActiveRecord::Base:Class (NoMethodError)
from /Users/Snake/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/railtie.rb:59:in `block (3 levels) in <class:Railtie>'
It think it might be something with version of rails a spree but I don't know were to start.
Does anybody had this issue before?
I running Mac OS X 10.5.8
rails 3.2.1
ruby 1.9.3p0 (2011-10-30 revision 33570) [i386-darwin9.8.0]
ImageMagick #6.7.4-6_0+q16
As #Anatoly Ruchka suggested the problem was using rails 3.2.1, so I switched to 3.1.3.
This is what I did, I found a post of #vonconrad where he explain how to create a rail project without touch the installation.
1) I create a directory folder for my project:
$mkdir old_rails313
$cd old_rails313
$touch gemfile
$nano gemfile
2)
I pasted a gemfile definition specifying as you mention the version of rails I want, so it looks like this
source 'http://rubygems.org'
gem 'rails', '3.1.3'
gem 'sqlite3'
group :assets do
gem 'sass-rails', '~> 3.1.5'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem "rspec-rails", ">= 2.8.0.rc1", :group => [:development, :test]
gem "factory_girl_rails", ">= 1.4.0", :group => :test
gem "cucumber-rails", ">= 1.2.0", :group => :test
gem "capybara", ">= 1.1.2", :group => :test
gem "database_cleaner", ">= 0.7.0", :group => :test
gem "launchy", ">= 2.0.5", :group => :test
#gem "devise", ">= 1.5.0"
gem 'spree','1.0.0'
3) then I run
bundle install
bundle exec rails new .
rails g spree:install
rails s
After installing I've got a conflict with the gem 'spree','1.0.0', so I comment it out.
Also I've got a warning but it works:
[DEPRECATION WARNING] Nested I18n namespace lookup under "activerecord.attributes.spree/order" is no longer supported
Thanks a lot
I think you should use rails version 3.1.3 for spree_usa_epay
TO do that you should uninstall all rails what you have on machine
to watch use
gem list -d rails
than
sudo gem uninstall rails -v ...
and create new project with
rails new my_store
than edit Gemfile and paste
gem 'spree', '1.0.0'
and
bundle install
well done
rails server

Can't activate rack when running cucumber

I can no longer run cucumber in my rails 3 app. I'm not sure exactly when it broke but I did do some rspec work that required me to use the webrat gem and it was working before that.
My error is:
$ cucumber
Using the default profile...
can't activate rack (~> 1.2.1, runtime) for ["actionpack-3.0.7", "railties-3.0.7"], already activated rack-1.3.0 for ["rack-test-0.5.7", "cucumber-rails-0.4.1"] (Gem::LoadError)
Here is my Gemfile
source 'http://rubygems.org'
gem 'rails', '3.0.7'
gem 'sqlite3'
gem 'devise'
gem 'rails_admin', :git => 'git://github.com/sferik/rails_admin.git'
gem 'cancan'
group :development, :test do
gem 'rspec-rails', '2.5.0'
gem 'rspec', '2.5.0'
gem 'webrat', ">= 0.7.2"
gem 'cucumber-rails'
gem 'capybara'
gem 'database_cleaner'
gem 'launchy'
gem 'factory_girl_rails'
gem 'spork'
end
Please let me know if I need to supply more info and I'll edit this.
I've tried specifying rack in my Gemfile but this doesn't seem to help and doesn't seem right. Also: If I modify my Gemfile I am running "bundle install" and then trying cucumber again. Is this the right workflow to solve this problem?
Can anyone please help?
Cheers,
Rim
Someone in my IRC channel pointed me in the right direction.
Use the context of bundler (which I don't quite understand yet)
bundle exec cucumber
This works just fine :)