ruby-on-rails-3.1

ActiveRecord::ConnectionTimeoutError happening sporadically

一世执手 提交于 2019-11-29 16:31:42
问题 Whenever I have an application using ActiveRecord I get this ConnectionTimeoutError - but always after a certain unknown period of time ActiveRecord::ConnectionTimeoutError (could not obtain a database connection within 5 seconds. The max pool size is currently 30; consider increasing it.): It was previously set to 5, we have already increased it, and there is no way it can be using 30 connections at the same time. The only thing we use ActiveRecord for is our session store. Our database.yml

Ruby on Rails: Custom Devise Registration Controller, Asking For Create Action

拜拜、爱过 提交于 2019-11-29 14:11:41
问题 I have a custom registration controller, but I don't want to override a create action from devise. When I try to sign up a user, I get this error: Unknown action The action 'create' could not be found for Devise::RegistrationsController Is it asking for it because I have a custom registration controller? If so, does that mean I need to copy all the actions that I'm not overriding from here: https://github.com/plataformatec/devise/blob/master/app/controllers/devise/registrations_controller.rb

Cucumber Rails 3.1 uninitialized constant ActionController::Dispatcher (NameError)

怎甘沉沦 提交于 2019-11-29 14:02:19
I am using a Rails 3.1 application and I was integrating cucumber to my app but when i try to run it I get this strange error, can someone help me please? Using the default profile... uninitialized constant ActionController::Dispatcher (NameError) /Users/chinog9/.rvm/gems/ruby-1.9.2-p180/gems/cucumber-rails-0.3.2/lib/cucumber/rails/action_controller.rb:51:in `rescue in <top (required)>' /Users/chinog9/.rvm/gems/ruby-1.9.2-p180/gems/cucumber-rails-0.3.2/lib/cucumber/rails/action_controller.rb:42:in `<top (required)>' /Users/chinog9/.rvm/gems/ruby-1.9.2-p180/gems/cucumber-rails-0.3.2/lib

RunTimeError: ActionController::RackDelegation in rspec 2.10.1 for rails 3.1.4 application controller

前提是你 提交于 2019-11-29 14:00:29
问题 In our rails 3.1.4 app, rspec is used to test the public method require_signin in application controller. Here is the method require_signin: def require_signin if !signed_in? flash.now.alert = "Log in first!" redirect_to signin_path end end Here is the rspec code: it "should invoke require_signin for those without login" do controller.send(:require_signin) controller {should redirect_to signin_path} end The above rspec generates gigantic multi pages error starting like the below: RuntimeError

facebook open graph crawler triggering json response in rails actions

笑着哭i 提交于 2019-11-29 13:51:08
For some reason the facebook crawler is triggering the json response in my rails actions. This causes the action to just return a json representation of the object, without the normal html markup + open graph tags. I have tested this with rails 3.2.6. I use the facebook open graph debugger to see what the scraper is seeing: http://developers.facebook.com/tools/debug . The code is very simple. Imagine a simple "show" action for an object, for example a User. It ends with: respond_to do |format| format.js { render :json => @this.to_json } format.html end The facebook crawler is triggering the

trying to get content inside cdata tags in xml file using nokogiri

自作多情 提交于 2019-11-29 13:12:28
I have seen several things on this, but nothing has seemed to work so far. I am parsing an xml via a url using nokogiri on rails 3 ruby 1.9.2. A snippet of the xml looks like this: <NewsLineText> <![CDATA[ Anna Kendrick is ''obsessed'' with 'Game of Thrones' and loves to cook, particularly creme brulee. ]]> </NewsLineText> I am trying to parse this out to get the text associated with the NewsLineText r = node.at_xpath('.//newslinetext') if node.at_xpath('.//newslinetext') s = node.at_xpath('.//newslinetext').text if node.at_xpath('.//newslinetext') t = node.at_xpath('.//newslinetext').content

Re-source .bashrc when restarting unicorn?

夙愿已清 提交于 2019-11-29 12:45:13
I have some ENV variables that are sourced for the deploy user. (Similar to what Heroku recommends , but without using Heroku.) My rails app depends on these for certain functions, for example, in application.rb: config.action_mailer.default_url_options = { host: ENV['MY_HOST'] } This is necessary because we have several staging hosts. Each host has MY_HOST defined to its correct hostname in .bashrc like so: export MY_HOST="staging3.example.com" This allows us to only use one rails staging environment, but still have each host's correct hostname used for testing, sending email, etc since this

cant use has_secure_password, password_digest error

孤者浪人 提交于 2019-11-29 12:35:09
问题 Good evening. I have a problem. i am using has_secure_password and cause of this i have an error undefined method password_digest=' for #`, but i dont have this method!! Please help, dont know what to do. I read how to fix this problem but it didnt help me( Here is my User model. Please help if you can. class User < ActiveRecord::Base attr_accessible :email, :password, :password_confirmation has_secure_password validates_presence_of :password, :on => :create before_create { generate_token(

Sprockets encoding error on js file: invalid UTF-8 byte sequence

て烟熏妆下的殇ゞ 提交于 2019-11-29 12:27:25
问题 A Sprockets::EncodingError exception is thrown when I include a file with characters that are valid utf-8. The line in question is: * Copyright (c) 2010 - 2011 Johan Säll Larsson If I replace the ä character, the problem goes away, but I don't want to have to remember to edit this vendor file everytime I update it. How can I fix this? 回答1: I found the solution via the comments on this Sprockets issue: I simply saved the file as utf-8, (TextMate has an option to do this when you chose 'Save As

Using Less in a Rails 3.1 App

ぃ、小莉子 提交于 2019-11-29 11:12:38
问题 I've just upgraded my application to the latest release of rails (3.1) and I'm wanting to integrate Twitter's Bootstrap into my application but it uses LESS and not SASS which is what Rails 3.1 uses by default. How do I go about configuring Rails to use Less instead of Sass? 回答1: As apneadiving points out, Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS. To configure your Rails app to support LESS, you can add the gem to the assets group of your Gemfile: group :assets do