ruby-on-rails-3.1

rake assets:precompile taking extremely long to complete

允我心安 提交于 2019-11-29 01:32:54
In my dev sandbox RAILS_ENV=production rake assets:precompile is taking over 4 minutes to complete. Is this normal. On heroku it is taking over 10 minutes to do the job and sometimes is timing out. Is there any way to disect this and/or speed it up? UPDATE I profiled the CSS vs JS phases of compilation 3.7 s js 175 s css The numbers were made by instrumenting here ---------------------- /Users/bradphelan/.rvm/gems/ruby-1.9.2-p180@gobbq/gems/sprockets-2.1.2/lib/sprockets/processing.rb ---------------------- 266 # Assign a compressor to run on `application/javascript` assets. 267 # 268 # The

Where to put Galleria (jQuery image gallery framework) in Rails 3.1 Asset Pipeline?

喜你入骨 提交于 2019-11-29 01:21:06
问题 I'm a bit confused as to where to put a jQuery framework like Galleria in Rails 3.1 's new Asset Pipeline ? I know it, technically, should go into /vendors/assets/javascripts but , it is my understanding that, the Galleria folder with the jQuery & themes wants to be in root ( /galleria ) of the live site in order to work correctly. Also, while we're at it, where to put the following script so it will appear only on the page(s) with a gallery? <script> $('#gallery').galleria({ width:500,

How to use multiple databases for one rails 3.1 app in Heroku?

爷,独闯天下 提交于 2019-11-28 23:31:52
My Rails 3.1 application connects to 2 databases, one is the default, the other is an Amazon RDS MYSQL instance. The current database.yml contains two production database connections. The models that need to pull from the second database simply use establish_connection "production_on_amazon" Unfortunately Heroku overwrites your database.yml, and only seems to inlcude one database connection. Does anyone know how I can add or configure my second? Running "heroku config" I can see there are 2 DB's listed but cant seem to configure to connect to both. Perhaps somehow set my default to the SHARED

Rails: Use livereload with Asset Pipeline

不打扰是莪最后的温柔 提交于 2019-11-28 23:25:45
Quick question for rails pros out there... When working with Rails 3.0.x apps I was a heavy user of Guard and LiveReload. However, it seems that when using the asset pipeline in Rails 3.1 the livereload guard does not know that changes to a Sass file should trigger sending new css to the browser. Is anyone using LiveReload with the Asset Pipeline? If so, how are you making it work? Thanks! After following some issue threads on Github I found the following fixed my problem: 1) Make sure all scss files are named following the new asset convention, like so: filename.css.scss I was using scss

How do I prevent Rails 3.1 from caching static assets to Rails.cache?

▼魔方 西西 提交于 2019-11-28 23:14:03
I'm using CloudFlare CDN on my Rails 3.1 application. Cloudflare is a CDN that works at the DNS level. On the first hit to a static asset, CloudFlare loads it from your app then caches it in their CDN. Future requests for that asset load from the CDN instead of your app. The problem I'm having is that if you set controller caching to true: config.action_controller.perform_caching = true it enables the Rack::Cache middleware. Since Rails sets a default cache control setting for static assets, those assets get written to the Rails.cache store. As a result my cache store (in my case redis) is

Listing 'rake routes' for a mountable Rails 3.1 engine

流过昼夜 提交于 2019-11-28 23:09:07
I'm working on a mountable engine for use with Rails 3.1, and I want to list the engine's routes. I created the engine using: $ rails plugin new rails_blog_engine --mountable And edited the 'test/dummy/config/routes' file to read: Rails.application.routes.draw do mount RailsBlogEngine::Engine => "/blog" end ...and 'config/routes' to read: RailsBlogEngine::Engine.routes.draw do resources :posts end I want to list the routes generated for ':posts', but it's not clear how I can do this. When I run 'rake app:routes', I get only the "/blog" route: $ rake app:routes rails_blog_engine /blog {:to=

Rails 3.1 Errno::EACCES Permission Denied

て烟熏妆下的殇ゞ 提交于 2019-11-28 22:55:38
Rails 3.1 Passenger on Apache Development environment When I go to access the index (i.e. GET) for a route I get: Errno::EACCES in Crb_agendas#index Showing /var/www/crbagenda/app/views/layouts/application.html.erb where line #5 raised: Permission denied - /var/www/crbagenda/tmp/cache/assets/E2C Extracted source (around line #5): 2: <html> 3: <head> 4: <title>CrbAgendas</title> 5: <%= stylesheet_link_tag "application" %> 6: <%= javascript_include_tag "application" %> 7: <%= csrf_meta_tags %> 8: </head> Rails.root: /var/www/crbagenda When I go to the path mentioned (/var/www/crbagenda/tmp/cache

rake assets:precompile is slow

孤者浪人 提交于 2019-11-28 22:53:44
The command "rake assets:precompile" works very slow for me. Especially on my Amazon EC2 Micro production server which does not have a lot of processor resources. On EC2 I have to wait 1 minute or more during each deployment just for this precompile task alone. Is there a way to make it faster? Previously I used Jammit to compress/minify css and js. Jammit worked nearly 10 times faster on the same web site and servers. If you don't need to load the Rails environment, you should disable that with: config.assets.initialize_on_precompile = false EDIT: I've just written a gem to solve this problem

When to create a new controller in rails

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 22:34:22
I'm wondering when you know that you need to create a controller in a rails application. For example, I'm going through the tutorial in Agile Web Development with Rails and the application creates several models, all with seperate views and contollers. However, we also then create a Store controller, but no model associated with it. Why do we need a controller with no model? Couldn't the controllers for the models handle all required operations? Is this common? If so, how do you determine when something warrants a controller? Thanks! These answers help, thank you. My concern is that when I

How to build task 'assets:precompile'

一曲冷凌霜 提交于 2019-11-28 22:17:25
问题 I'm getting that error on my production server, and can't figure out why. It happens when running this command: bundle exec rake assets:precompile RAILS_ENV=production I'm using Rails 3.1.0.rc6 回答1: This is most likely due your config/application.rb not requiring rails/all (the default), but some custom requires. To resolve this, add the following to config/application.rb : require 'sprockets/railtie' 回答2: I know this is an old post but I thought it might help someone (probably my future self