ruby-on-rails-3.1

How to optimize the asset compilation rake task in Rails 3.1 while deploying eating up the all memory?

此生再无相见时 提交于 2019-12-14 04:11:37
问题 The production box is of 768MB node at Linode. When I am deploying a Rails 3.1 app, the asset compilation takes place which invokes other 2 rake tasks with the Rails app env loaded. So, one task is occupying 30% of the memory which makes the 3 tasks to 90% of the memory and the capistrano command dies with zlib(finalizer): the stream was freed prematurely. error. Its getting me frustrated since it has already ate my whole day!! 回答1: This is know rails issue. You can find one solution here 来源:

javascript - Twitter bootstrap jquery plugins not compiled for production

送分小仙女□ 提交于 2019-12-14 03:41:18
问题 I'm developing a 3.1 Rails app with Twitter Bootstrap using seyhunak's gem. On the production mode, I was able to use basic bootstrap CSS and JS through pipeline precompilation: RAILS_ENV=production bundle exec rake assets:precompile Using the gem file : group :assets do gem 'sass-rails', '~> 3.1.5' gem 'coffee-rails', '~> 3.1.1' gem 'uglifier', '>= 1.0.3' gem "twitter-bootstrap-rails" end And the application.js file: //= require_tree . //= require jquery //= require jquery_ujs //= require

Rails 3.1.0 - undefined method `page_cache_extension' for ActionController::Base:Class

无人久伴 提交于 2019-12-14 03:40:53
问题 When I try load my rails 3.1 app I just get this error. Any ideas? undefined method 'page_cache_extension' for ActionController::Base:Class 回答1: somewhere I've read that it could be caused because of empty database - do You have one? Check if there You have any records ;) This resolved my problem with it. 回答2: I removed the following lines from development.rb config.action_view.debug_rjs = true config.action_controller.perform_caching = false Not sure if this is right, but it worked for me.

Association between Post and Location

隐身守侯 提交于 2019-12-14 03:34:04
问题 This my first ruby on rails application. Model Location and Post, Location has many post.I create location as tree structure with ancestry gem. class Post < ActiveRecord::Base belongs_to :location, :counter_cache => true end class Location < ActiveRecord::Base include Tree has_ancestry :cache_depth => true has_many :posts end This my Post Controller class PostsController < ApplicationController before_action :set_post, only: [:show, :edit, :update, :destroy] def index @posts = Post.all end

Rails 3.1 404 Error when loading .css files that are present in public/assets

橙三吉。 提交于 2019-12-13 21:35:00
问题 I've got an application I've been running in development for a long time, and recently switched to running it in production to better test things out. Assets are no longer loading, so the entire look of the application is wrecked. I see errors like this in console: cache: [GET /assets/login-b5cc6c1d02b7c2fe3fd9e365a0d6ff82.css] miss cache: [GET /assets/main-9f54f3726daba54b6104bfa715be64d7.css] miss If I go ahead and login: cache: [GET /] miss ---------------------- authorize user -----------

How to import ruby on rails project

北战南征 提交于 2019-12-13 20:25:04
问题 I am trying to import a project that someone else build 1 year ago, now my mac have already installed all below which include: ruby, rails and mysql paperclip dragonfly authlogic sqlite3-ruby uuid rmagick thin or mongrel nokogiri rack-cache pony tiny_mce could any one tell how to import the project, or any link on line can help me? 回答1: There is no such thing called import a rails project, If you have ruby installed, the you could use bundler to manage your gems via the Gemfile if your

ruby on rails 3.1 global exception handler

你。 提交于 2019-12-13 19:16:13
问题 I'm developing an app with Rails 3.1.2 but I can't find some documentation that works with errors / exception (like 404) on this version of rails. i have tried things like: In application controller rescue_from ActiveRecord::RecordNotFound,ActionController::RoutingError, ActionController::UnknownController, ActionController::UnknownAction, :NoMethodError, :with => :handle_exception def handle_exception render :template => 'error_pages/error' end environment/development.rb config.consider_all

Use Rails 3.1 Asset Paths in a SCSS Partial

假如想象 提交于 2019-12-13 14:41:03
问题 I have the following setup: app/assets/stylesheets/application.css.scss /* *= require_self *= require fancybox */ /* COLORS.. */ /* MIXINS... */ /* FONT STACKS... */ /* IMPORTS */ @import "reset"; @import "supergrid"; @import "rails"; @import "app"; @import "forms"; @import "layout"; In my various partials I'm having a real problem with the asset paths. When inside application.css.scss or anything loaded by the manifest, I can use: .example { background-image: image-path("background.png"); }

rails 3.1 generating CSV file

こ雲淡風輕ζ 提交于 2019-12-13 13:02:02
问题 I am able to export table data to a CSV file, however there is a blank row after every record. Why and how do i fix it? in index.html.erb <%= link_to "Export to csv", request.parameters.merge({:format => :csv})%> in index.csv.erb <%- headers = ["Id", "Name"] -%> <%= CSV.generate_line headers %> <%- @customers.each do |n| -%> <%- row = [ n.id, n.fname ] -%> <%= CSV.generate_line row %> <%- end -%> 回答1: CSV.generate_line adds a new line character to the end of the line it generates, but so does

Updating more than one attribute at one time in ruby on rails

两盒软妹~` 提交于 2019-12-13 07:15:33
问题 I have a page where a user can see a list of messages in a current threaded conversation. They can delete each message using a delete link (a link inside an each loop for each message): <%= link_to 'Delete', message, :method => :delete, :confirm => "Are you sure?", :title => message.body %> <br /> This basically connects them to an action in my messages_controller: def destroy @message = Message.find(params[:id]) @message.update_attribute('sender_status', 1) if @message.sender_id == current