ruby-on-rails-3.1

Dependency included in gemspec not added to asset pipeline in rails engine

早过忘川 提交于 2019-12-03 09:52:15
I'm writing a rails engine that has some dependencies. I've specified the dependencies in the gemspec and the engine is finding them when I run bundle install (i.e. Gemfile.lock looks correct). When I want to use the plugin in a Ruby file, I can do so but need to explicitly require dependency-name at the top of the file. However, when I want to use the dependency's asset pipeline, sprockets can't find it. The app I'm using (for now) is the dummy app that comes in a rails plugin's test folder. Sprockets can find the assets if I specify them in the engine's Gemfile (which is really the dummy app

What path is a mountable engine mounted on

别等时光非礼了梦想. 提交于 2019-12-03 09:41:04
问题 I need to know, from inside of a layout of a mountable engine, what path it's currently being mounted on. What would be the way to do it? E.g. my routes.rb contains the following line: mount BackendCore::Engine => "/backend" From inside of the BackendCore, I need the access to the value of "/backend". 回答1: If the engine is mouted :as => a different name, querying named_routes will not be sufficient. This monkey patch will do: class Rails::Engine def self.mounted_path route = Rails.application

ruby on rails 3.1 move .swf to asset pipeline?

∥☆過路亽.° 提交于 2019-12-03 09:40:16
Is it possible to move SWF files to the asset pipeline, and if possible how can this be done? Richard Hulse I would recommend putting them in a folder called app/assets/flash . Add this folder to your asset paths: config.assets.paths << Rails.root.join('app', 'assets', 'flash') They can be referenced like this in your views: asset_path('name_of_swf') The asset_path helper will ensure the correct file is referenced in development and production modes. 来源: https://stackoverflow.com/questions/8990393/ruby-on-rails-3-1-move-swf-to-asset-pipeline

How do I add Devise's 'timeoutable' module to an existing Devise install? - Rails 3.1

扶醉桌前 提交于 2019-12-03 09:38:13
These are the instructions to add a module to an existing Devise install: https://github.com/plataformatec/devise/wiki/How-To:-change-an-already-existing-table-to-add-devise-required-columns But I can't seem to locate the necessary columns for timeoutable . I looked for the fields that timeoutable requires in the Devise library: https://github.com/plataformatec/devise/blob/master/lib/devise/schema.rb - but there is no such method in that schema file. The model just has a custom method with no reference to the columns: http://rdoc.info/github/plataformatec/devise/master/Devise/Models

Rails 3.1 on Ubuntu 11.04 via RVM - uninitialized constant Psych::Syck

拈花ヽ惹草 提交于 2019-12-03 09:30:19
gem install rails --pre ERROR: While executing gem ... (NameError) uninitialized constant Psych::Syck I can't seem to find any info on how to resolve this. Has anyone else had the same problem? I am using a newly created gemset in RVM with Ruby 1.9.2 I had exactly same problem on mac via RVM. Specifying version is the rescue for me. gem install rails --pre --version 3.1.0.rc1 update (2011-06-12) with rubygems 1.8.4, I can install rails 3.1.0.rc4 without specifying the version. I had exactly the same problem, and the other solutions mentioned here didn't work for me. However, this did: gem

Ruby syntax: break out from 'each.. do..' block

淺唱寂寞╮ 提交于 2019-12-03 09:19:01
I am developing a Ruby on Rails app. My question is more about Ruby syntax. I have a model class with a class method self.check : class Cars < ActiveRecord::Base ... def self.check(name) self.all.each do |car| #if result is true, break out from the each block, and return the car how to... result = SOME_CONDITION_MEET?(car) #not related with database end puts "outside the each block." end end I would like to stop/break out from the each block once the result is true (that's break the each block if car.name is the same as the name parameter once ) AND return the car which cause the true result.

Static pages and assets in Rails 3.1.1

久未见 提交于 2019-12-03 08:56:51
Currently working on a project where we need to drop in various static html pages + static assets for those from time to time that "just work." We cannot have anyone editing the html directly to place paths in for the assets. We need it to simply work such that the html + asset folders are placed directly into /public and the content is served up as it was generated. When testing this behavior in production, it's a no go with errors such as: ActionController::RoutingError (No route matches [GET] "/some_folder/some-image.png"): I assume this is a result from what I'm reading from 3.1.x's asset

Passenger & Nginx => 502 Bad Gateway Errors in Production

那年仲夏 提交于 2019-12-03 08:44:26
I am running Nginx 1.0.6, Passenger 3.0.9, Rails 3.1.1, Ruby 1.9. In my production environment I am seeing the following intermittent warnings in my nginx_error.log file: 2011/11/22 14:44:40 [warn] 23288#0: *474 an upstream response is buffered to a temporary file /opt/nginx/proxy_temp/2/00/0000000002 while reading upstream, client: 69.172.88.178, server: www.memverse.com, request: "GET /show_all_my_verses HTTP/1.1", upstream: "passenger:unix:/passenger_helper_server:", host: "www.memverse.com", referrer: " http://www.memverse.com/quick_add/7352 " and, less frequently, the following error

Rails counter_cache not updating correctly

可紊 提交于 2019-12-03 08:35:25
问题 Using Rails 3.1.3 and I'm trying to figure out why our counter caches aren't being updated correctly when changing the parent record id via update_attributes. class ExhibitorRegistration < ActiveRecord::Base belongs_to :event, :counter_cache => true end class Event < ActiveRecord::Base has_many :exhibitor_registrations, :dependent => :destroy end describe ExhibitorRegistration do it 'correctly maintains the counter cache on events' do event = Factory(:event) other_event = Factory(:event)

Couldn't find User with id=1

自作多情 提交于 2019-12-03 08:34:38
I've a current_user method to handle authentication. application_controller.rb protect_from_forgery helper_method :current_user def current_user @current_user ||= User.find(session[:user_id]) if session[:user_id] end but when I try to acces a to a page I get the following error: Couldn't find User with id=1 app/controllers/application_controller.rb:10:in `current_user' How can I pass @current_user a sort of default value so if there's no user it will redirect to login page. Thanks for helping. It looks like your session contains old data, specifically an id (1) of a user which no longer exists