ruby-on-rails-3.2

How can I make Rails 3 assets precompile faster?

有些话、适合烂在心里 提交于 2019-12-02 16:40:39
I have a running Rails 3.2.1 application, that I'm deploying via Capistrano with the deploy/assets which runs the deploy:assets:precompile task. Everything works just fine, except that the compilation itself is really slow. I don't have that much CSS and JavaScript (about 8200 lines total). It generally takes about 1-3 minutes to compile the assets, which is about 90% of the whole deployment time. Is there any way to optimize this? Maybe use a different procedure to compile the assets or somehow optimize it? I'm running the app on Linode 512 on 1.9.2-p290, Rails 3.2.1 and using therubyracer

REXML::Document.new can we give encode parameters on this line?

邮差的信 提交于 2019-12-02 16:36:34
问题 doc = REXML::Document.new file My code is failing at this point whenever my xml file contains some special characters other than UTF-8 . REXML::ParseException (#<REXML::ParseException: #<ArgumentError: invalid byte sequence in UTF-8> 回答1: You can call something like this REXML::Document.new(file.force_encoding("FILE_ENCODING").encode("UTF-8")) FILE_ENCODING is the encoding of your file variable. 来源: https://stackoverflow.com/questions/17194393/rexmldocument-new-can-we-give-encode-parameters

How to debug a Rails asset precompile which is unbearably slow

醉酒当歌 提交于 2019-12-02 16:09:57
I'm working on a Rails 3.2 project and the assets have increased a fair bit in recent months although I wouldn't consider the project to be large. The assets consist of JS (no coffee-script), and SASS files; we've quite a few images but they've been there more less since the early days so I don't think they are a substantial factor. We may have about a dozen libs and most are small, the largest is Jquery UI JS. Deployment is done via Capistrano and it started to become apparent that deploying to staging was significantly faster than to production. To illustrate whilst avoiding factors about

How to use Eclipse for Ruby on Rails (RoR)

谁说我不能喝 提交于 2019-12-02 15:33:08
I am new in Ruby. I have installed Ruby on Rails on Windows 7. I visited the following to choose a suitable IDE/Editor for writing Ruby code: http://rubyonrails.org/download I found the following Editors for Ruby: VIM for Rails, RadRails, RubyMine, 3rd Rail, Netbeans for Ruby I am familiar with Eclipse as I am using Eclipse for java. Can I use Eclipse for Ruby? If so, what configuration is necessary in Eclipse for Ruby project? Bryan Wolfford To save you some legwork, in Eclipse: Go to Help -> Install New Software... Click add (top right of popup) Enter a Name like "RadRails2" Enter the

Sending files to a Rails JSON API

一世执手 提交于 2019-12-02 15:11:57
I know there are questions similar to this one, but I've not found a good answer yet. What I need to do is send a description of an object to one of my create methods, which includes some different attributes including one called :image, a paperclip attachment: has_attached_file :image Now I've read that sending the image could be done straight in JSON by encoding and decoding the image as base64, but that feels like a dirty solution to me. There must be better ways. Another solution is sending a multipart/form-data request, much like the one LEEjava describes here. The problem with that one

How can i remove a column from table using rails console

倖福魔咒の 提交于 2019-12-02 14:49:25
It is easily possible to remove a column using rails migration. class SomeClass < ActiveRecord::Migration def self.up remove_column :table_name, :column_name end end I want to know if there is any way to remove a column from table using console. You can run the codes in up method directly in rails console : >> ActiveRecord::Migration.remove_column :table_name, :column_name If you already have a migration file such as " db/migrate/20130418125100_remove_foo.rb ", you can do this: >> require "db/migrate/20130418125100_remove_foo.rb" >> RemoveFoo.up If you just want to do rake db:migrate , try

Configuration rails3 actionMailer for Google Compute Engine times out

孤人 提交于 2019-12-02 14:41:26
问题 Getting a: Timeout::Error (execution expired): app/controllers/acts_controller.rb:192:in `send_message' GCE requires sendgrid and following there indications I adapted the port to "2525" as per GCE's documentation. So the environment.rb file is require File.expand_path('../application', __FILE__) Paperclip.options[:command_path] = "/usr/bin/" ActionMailer::Base.smtp_settings = { :user_name => ENV["SENDGRID_USERNAME"], :password => ENV["SENDGRID_PASSWORD"], :domain => ENV["DOMAIN"], :address =

Configuration rails3 actionMailer for Google Compute Engine times out

倖福魔咒の 提交于 2019-12-02 11:50:44
Getting a: Timeout::Error (execution expired): app/controllers/acts_controller.rb:192:in `send_message' GCE requires sendgrid and following there indications I adapted the port to "2525" as per GCE's documentation . So the environment.rb file is require File.expand_path('../application', __FILE__) Paperclip.options[:command_path] = "/usr/bin/" ActionMailer::Base.smtp_settings = { :user_name => ENV["SENDGRID_USERNAME"], :password => ENV["SENDGRID_PASSWORD"], :domain => ENV["DOMAIN"], :address => 'smtp.sendgrid.net', :port => 2525, :authentication => :plain, :enable_starttls_auto => true } #

Scope that has three levels deep joins

 ̄綄美尐妖づ 提交于 2019-12-02 08:25:42
My Program table has many Measures My Measure table has many Targets My Target table has a column called " money " My ActiveRecord query looks like this: @programs2 = Program.includes([measures: :target]).where('organization_id = 1').limit(2) I want to define a scope such that the query can return top Programs that their target.money value is the lowest. So I need to write a scope and apply it to that query but How and Where in the model should I define that scope, something like this? Well this won't work but that's as much as I know. scope :top5, :joins => [:measures, :targets] , :order =>

Routing errors when upgrading from rails 3.1 to rails 3.2 due to underscores in module namespaces

可紊 提交于 2019-12-02 06:45:23
We have a rails application and we have a API namespace defined as Api::V1, Api::V1_2, Api::V1_3 etc. In routes.rb, we have set the following namespace :api do ["v1", "v1.2", "v1.3", "latest"].each do |name| namespace name, {:module => name.gsub(".","__"), :as => name.gsub(".","_") } do constraints :format => /json/ do # user scoped views resources :some_endpoint, :only => [:create, :index, :show, :update, :delete], :path => "scheduler" do member do put 'edit' post 'duplicate' end end end end end It works fine when running with Rails 3.1, but we get a routing error in rails 3.2 of the form: