ruby-on-rails-3.1

dots in URL routes with namespace rails 3.1

心已入冬 提交于 2019-12-23 18:15:00
问题 I have this in routes.rb root :to => "posts#index" devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" } resources :users, :only => :show resources :boards resources :posts do resources :comments end namespace :users do resources :posts do get :posts, :on => :member end resources :boards do get :boards, :on => :member end end rake routes: boards_users_board GET /users/boards/:id/boards(.:format) {:action=>"boards", :controller=>"users/boards"} users_boards

Rails 3.1 on Apache, PageSpeed says “Specify Cache Validator” when using Asset Pipeline apache config

别等时光非礼了梦想. 提交于 2019-12-23 18:07:51
问题 I am seeing a conflict between what Rails 3.1 guides suggest, and what Google PageSpeed suggest for managing of cached assets. Rails 3.1 guides for asset pipeline offer a solution Apache server configuration here The salient bit of apache config is: <LocationMatch "^/assets/.*$"> # Some browsers still send conditional-GET requests if there's a # Last-Modified header or an ETag header even if they haven't # reached the expiry date sent in the Expires header. Header unset Last-Modified Header

Ruby Gem for mysql 5.5 in windows

大兔子大兔子 提交于 2019-12-23 17:24:32
问题 We are going to use mysql 5.5 in our application for production. I did some online search and it seems that mysql2 0.2.6 is the one for mysql5.5. Is this gem good for windows as well? Any tips on how to install and manage for production? Thanks. 回答1: The gems (either mysql or mysql2) provides an version-independent layer to the version of MySQL you are running. However, if you're using a pre-compiled gem, it will require a version specific MySQL library be installed in your system. To avoid

Rails 3.1 Asset Pipeline - turn off image asset fingerprinting on Heroku?

半城伤御伤魂 提交于 2019-12-23 15:33:38
问题 Because a jQuery plugin I use in my application has direct references to images, I'm trying to turn off asset fingerprinting. So I set config.assets.digest = false in my production.rb, but now none of my image references work at all. /assets/foo.png just returns a blank response. I really don't want to alter the jQuery plugin's code and add erb image helpers, but I'm not sure what else to do. And frankly, the asset fingerprinting for images seems to be much more trouble than it's worth. Does

will_paginate show the last page by default (keeping chronological order)

微笑、不失礼 提交于 2019-12-23 13:02:07
问题 I'm building an index page where I need to display results which have a date, ordered chronologically (from the earliest date to the newest one), but I need to always show the last page by default. I can't use a DESC order for the date because it would defeat the whole purpose of what I need this for =(. TL;DR: I need to show a paginated log list, sorted by date ascending, but starting in the last page. Is this possible with will_paginate? Thanks! 回答1: You can build your query, get the total

Rails open-uri breaking on path

放肆的年华 提交于 2019-12-23 12:29:43
问题 I'm trying to get a url using open-uri. my code is outrageously simple url = open("http://localhost:3000/descriptions") return render :text => url.to_json When I run this code, I get a timeout error. When I request just "http://localhost:3000", I get my home page (which is correct). So it seems this is breaking on the path somewhere. I've tried using net-http with uri (not sure if that would make a difference) and I still have the same issue. I want to get a path and a query, but I can't seem

Capistrano deploy/assets on Rails 3.1 fails

南笙酒味 提交于 2019-12-23 10:08:36
问题 I added the this line load 'deploy/assets' to my Capfile to deploy assets with Rails 3.1. Capistrano gets to this line * executing "cd /home/deploy/armonia/stage/releases/20110928021521 && bundle exec rake RAILS_ENV=stage RAILS_GROUPS=assets assets:precompile" then fails with Could not find multi_json-1.0.3 in any of the sources which is weird because the gem is found when I run bundle show multi_json on my deployment server. What causes this? 回答1: Fixed this by updating to bundler to 1.0.18,

How can i use accepts nested attributes with the HABTM?

試著忘記壹切 提交于 2019-12-23 09:47:47
问题 I have two models User and Category. class User < ActiveRecord::Base has_and_belongs_to_many :categories accepts_nested_attributes_for :categories end similarly class Category < ActiveRecord::Base has_and_belongs_to_many :users end i have a requirement where i have to add the categories to the categories table and add the reference so that i can get the categories related to user but if another user enters the same category then i have to make use of the id instead of creating new one. How

Rails 3.1 Devise How To Change Flash Message CSS From notice to success?

跟風遠走 提交于 2019-12-23 09:21:10
问题 Rails 3.1 and Devise 1.5 question. I'm using the following code to display flash messages in my layout: <% flash.each do |key, message| %> <%= content_tag(:div, message, :class => "flash #{key}") %> <% end %> I'd like to change the css class for some of my confirmation messages from notice to success, but I don't know where to override or change the key because I don't know where it's set. Can anybody point me in the right direction? Thanks! 回答1: So the way to do this is to edit the devise

Asset Pipeline not finding JS file

天涯浪子 提交于 2019-12-23 07:00:13
问题 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