ruby-on-rails-3.1

Clear the cache from the Rails asset pipeline

时光总嘲笑我的痴心妄想 提交于 2019-11-28 03:48:37
I'm starting a new project in Rails, and it looks like the application.js manifest file is doing something funny with the javascripts that I reference - does it cache those files as part of the asset pipeline? Here's what happened. I added a javascript file named jquery.autoresize.js to the vendor/assets/javascripts folder, and then referenced the file in the application.js manifest like this: //= require jquery.autoresize.js Then I started up the rails server. But after navigating around in my app, I realized that I had accidentally added the wrong version of the jquery.autoresize.js file. So

How to avoid precompiled assets being served in development mode?

孤街醉人 提交于 2019-11-28 03:27:17
I prefer not to concatenate JavaScript files in development mode, but serve them as individual files. So I configured: development.rb: config.assets.compress = false config.assets.debug = true config.assets.compile = true In my /app/assets/javascript directory I have: reviews.js reviews/ foo.js bar.js reviews.js: //= require jquery //= require jquery_ujs //= require_tree ./reviews I include the JavaScript using <%= javascript_include_tag "reviews" %> in my layout. The generated page correctly references the three scripts individually and reviews.js is essentially empty. So far so good. Now

How to set up factory in FactoryGirl with has_many association

主宰稳场 提交于 2019-11-28 03:22:13
Can someone tell me if I'm just going about the setup the wrong way? I have the following models that have has_many.through associations: class Listing < ActiveRecord::Base attr_accessible ... has_many :listing_features has_many :features, :through => :listing_features validates_presence_of ... ... end class Feature < ActiveRecord::Base attr_accessible ... validates_presence_of ... validates_uniqueness_of ... has_many :listing_features has_many :listings, :through => :listing_features end class ListingFeature < ActiveRecord::Base attr_accessible :feature_id, :listing_id belongs_to :feature

Warning. Error encountered while saving cache … can't dump anonymous class

夙愿已清 提交于 2019-11-28 03:13:10
问题 When app is deployed with capistrano errors occur in production.log. Compiled signup.css (30ms) (pid 31797) Warning. Error encountered while saving cache /home/deployer/apps/example.com/releases/20140315211501/tmp/cache/sass/c76a96d592cb37dc7092a4e2f10ad8d3d22bcc8b/user_sessions.css.scssc: can't dump anonymous class #<Class:0x0000000356d120> Compiled user_sessions/user_sessions.css (16ms) (pid 31797) Compiled user_sessions.css (20ms) (pid 31797) Warning. Error encountered while saving cache

Testing Rails 3.1 mountable engine with Rspec

三世轮回 提交于 2019-11-28 03:12:09
I started making a Rails 3.1 engine, and I'm having a hard time testing it using rspec. First of all, if I run rails g integration_test whatever it creates a regular integration test in tests/integration instead of spec/requests (the rspec-rails gem is installed and required as a development dependency in the gemspec file) Also, when I run a spec test I get an error saying the table corresponding to the model I'm testing has not been created. I tried rake engine_name:install:migrations and running rake db:migrate from inside the dummy app, and I get a "table already exists" error. Everything

Add a new asset path in Rails 3.1

这一生的挚爱 提交于 2019-11-28 03:07:44
Does anyone know how to add another folder to the asset pipeline in Rails 3.1? I'd like to serve app/assets/fonts the same way app/assets/images is served. Update: 5-7-2013 Just to add some clarification for future people who find this question to explicitly add an asset path, in your application.rb file: config.assets.paths << "#{Rails.root}/app/assets/fonts" However, since the above path is under app/assets you don't have to add it explicitly, you just need to restart your rails app so Sprockets can pick it up. You will have to explicitly add paths that are outside of app/assets , lib/assets

execJs: 'Could not find a JavaScript runtime' but execjs AND therubyracer are in Gemfile

≯℡__Kan透↙ 提交于 2019-11-28 02:48:34
I'm getting this error: rake aborted! Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs , I have already spent more hours searching google then I am willing to admit. I believe this is an execJs bug. From all the posts, this is a very common issue with rails 3.1. A js runtime is now needed by what are now standard gems like coffee-script and sass. Most of these cases were resolved by adding the gems 'execjs' and 'therubyracer' to the app Gemfile, and then running 'bundle update' and/or 'bundle install'. But not for me. I guess I got lucky. I am running rails 3.1.3

asset_path in scss file rails

心不动则不痛 提交于 2019-11-28 02:40:49
问题 I am having issues with asset_path in production. Rails 3.1.1 #config/environments/development.rb Scc::Application.configure do # Settings specified here will take precedence over those in config/application.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Log error messages when you

Rails 3.1 newbie : where should I put javascript code?

爷,独闯天下 提交于 2019-11-28 00:02:19
问题 I am developing Rails 3.1 application, I get confused about where should I put my own javascript code(e.g. my.js ) and where to put 3rd-party javascript library (e.g. jQuery-UI ). I know in the old version Rails, javascript should all goes into public/javascripts/ directory, when I generate Rails 3.1 app, there is no public/javascripts/ folder, but there is app/assets/ and verndor/assets/ and there is application.js in app/assets , I would like to ask: in Rails 3.1 ,where should I put my.js

Cookies do not persist in Rspec on rails 3.1

淺唱寂寞╮ 提交于 2019-11-27 23:52:45
This is a problem with the cookies collection in a controller spec in the following environment: rails 3.1.0.rc4 rspec 2.6.0 rspec-rails 2.6.1 I have a simple controller spec that creates a Factory user, calls a sign in method which sets a cookie, and then tests to see if the signed in user may access a page. The problem is that all cookies seem to disappear between the authentication cookie being set and the "show" action being called on my controller. My code works fine when run in a browser on the rails dev server. The even stranger behavior while running the spec is that everything set