ruby-on-rails-3.1

Asset Pipeline not finding JS file

别等时光非礼了梦想. 提交于 2019-12-23 07:00:04
问题 My Rails.application.config.assets.paths contains the directory for an asset I'd like (autocomplete): - /Users/kiranb/application/app/assets/images - /Users/kiranb/application/app/assets/javascripts - /Users/kiranb/application/app/assets/stylesheets - /Users/kiranb/application/vendor/assets/javascripts - /Users/kiranb/application/vendor/assets/stylesheets - /Users/kiranb/.rvm/gems/ruby-1.9.2-p290@application/gems/rails3-jquery-autocomplete-1.0.5/lib/assets/javascripts - /Users/kiranb/.rvm

How to deal with image references in CSS in a Rails 3.1 app

大兔子大兔子 提交于 2019-12-23 04:49:05
问题 I just upgraded my rails app to 3.1 and I'm making use of the new asset pipeline. With the pipeline in place it's imperative that any static references made in your application utilize the rails helper methods, ie, asset_path(...), img_tag(), etc.... Here's the question, how do I fix the static references in my css files? 回答1: In Rails' SASS files, there's an image-url() function you can use like so: .page { background: #eee image-url('somefile.png'); } Rails will look for that file in all

Error trying to download using filnename format

荒凉一梦 提交于 2019-12-23 04:28:25
问题 I'm trying to customize the format when i'm saving to xls : I want help customizing= "Date" + "ejecutive selected" + ".xls" But is not working My models class Policy < ActiveRecord::Base unloadable belongs_to :ejecutive has_many :policy def self.search(search) if search find(:all, :conditions => ["ejecutive_id = ? ", search.to_i ] ) else find(:all) end end end class Ejecutive < ActiveRecord::Base has_many :policies end Here is my controller. Here i put my format that i'm trying to customize

new action trying to use show

試著忘記壹切 提交于 2019-12-23 04:26:54
问题 Here are my routes: equipment_index GET /equipment(.:format) {:action=>"index", :controller=>"equipment"} POST /equipment(.:format) {:action=>"create", :controller=>"equipment"} new_equipment GET /equipment/new(.:format) {:action=>"new", :controller=>"equipment"} edit_equipment GET /equipment/:id/edit(.:format) {:action=>"edit", :controller=>"equipment"} equipment GET /equipment/:id(.:format) {:action=>"show", :controller=>"equipment"} PUT /equipment/:id(.:format) {:action=>"update",

Arel: order by association count

本秂侑毒 提交于 2019-12-23 03:37:13
问题 Here is what I'm trying to do class Question has_many :votes end class Vote belongs_to :question end I want to find all questions ordered by the number of votes they have. I want to express this in Arel (in Rails 3) without using any counter caches. Is there any way of doing this ? Thanks. 回答1: Try this: Question.select("questions.*, a.vote_count AS vote_count"). joins("LEFT OUTER JOIN ( SELECT b.question_id, COUNT(b.id) AS vote_count FROM votes b GROUP BY b.question_id ) a ON a.question_id =

How to remove infinite redirect loop after I set force_ssl to false in heroku?

折月煮酒 提交于 2019-12-23 02:34:09
问题 I'm working on a Rails 3.1.0 app that needs to have ssl in some pages depending on the user. I setted config.force_ssl to false in config/enviroments/staging.rb. Added a before filter that decides whether or not to redirect to http. The redirect works in development if I clean the cache. The thing is in staging, it results in a redirect loop. I believe that force_ssl uses a permanent redirect, therefore when the DNS is asked about a page in my app, it still tries to redirect to the page with

How to write an image to filesystem in rails 3.1.1?

落花浮王杯 提交于 2019-12-23 01:45:16
问题 I feel like I should be really close, but I can't get this to work just quite right. I'm sending an image using filetransfer from my phonegap app to my rails app (3.1.1 ruby 1.8.7 btw). I want to write the file to the filesystem. This is the params hash: Parameters: {"file"=>#<ActionDispatch::Http::UploadedFile:0x7f1e2baa94e8 @tempfile=#<File:/tmp/RackMultipart20120607-5707-owzii5-0>, @headers="Content-Disposition: form-data; name=\"file\"; filename=\"image.jpg\"\r\nContent-Type: image/jpeg\r

Error Messages Showing in Production - Ruby on Rails 3.1, Nginx, Unicorn

心已入冬 提交于 2019-12-23 00:47:06
问题 I have a Rails 3.1 app running in production using Nginx and Unicorn. And for some reason, my custom 404 and 500 html error pages are not showing. Instead I'm getting the actual error message ("Routing Error", for example). In my production.rb file, I have config.consider_all_requests_local = false And on the same server with a nearly identical configuration, I have a 'staging' site that works just fine. The only difference, as far as I can tell, is that the production one has SSL while the

ruby on rails 3.1 web design

孤者浪人 提交于 2019-12-22 18:09:36
问题 May I ask you how to make rails web design more efficient? Is compass plus blueprint the perfect match? Is the current version of compass support rails3.1 Are there any other frameworks that will make rails web deign easier? Thanks 回答1: Definitely a framework like compass is awesome, it includes a lot of helpers, and provides a good solid base. For form-styling I would recommend using a gem like [formtastic][1], which not only greatly simplifies making forms, but also provides a standard css

run rake task inside rails application

天大地大妈咪最大 提交于 2019-12-22 17:37:32
问题 I want to run asset precompile task inside the rails application,As I had many dependencies who will change the code,in that case all the time whenever they change i need to run the script as I cant give server access to them so I am providing the GUI for them from that they alone can run the script,so,I have built UI to run the task with some parameter like system("Template='#{params[:template]}' Theme='#{params[:theme]}' rake assets:precompile) I am getting two values from UI(params[