ruby-on-rails-3.2

Rails can't find the module, if config.cache_classes = true

雨燕双飞 提交于 2019-12-10 17:14:39
问题 I have a gem which is mounted as engine in my rails app via routes.rb & Gemfile . Here are the important pieces: Apps' Gemfile source 'https://rubygems.org' gem 'rails', '3.2.9' gem 'mysql2' group :assets do gem 'sass-rails' gem 'coffee-rails' end gem 'jquery-rails' gem "common_client", path: "../common-client" App's routes.rb mount CommonClient::Engine => "", :as => 'shared' gem's routes.rb get '/register' => 'session#new_registration' gems's SessionController require 'common_client/session

Commandline statement inside rails controller

半城伤御伤魂 提交于 2019-12-10 16:55:34
问题 How to execute rails commandline statement inside our rails controller eg: I need to execute this statement $rails new test -d postgresql from my rails controller def index / Code to execute the command line statement / end Hope am clear.. 回答1: If you want to run shell commands inside controller just use "system" Eg: system "rails new test -d postgresql" or else exec "rails new test -d postgresql" 回答2: Use backticks to shell out, like this: `rails new test -d postgresql` It might be smarter

Styling the date fields of a Rails date_select

不羁岁月 提交于 2019-12-10 16:12:36
问题 In Rails' forms, date select drop-downs are easy: <%= f.label :my_date %> <%= f.date_select :my_date %> Then I get 3 select drop-downs for the year, month and day. Is there an easy way to add HTML between these select elements without using JavaScript? I want to be able to style and label them nicer. 回答1: Convert it to a text field and add a JQuery datepicker or similar. Theres a good guide here, http://railscasts.com/episodes/213-calendars 回答2: You can easily style them with CSS as each part

User authentication by both ldap and database

China☆狼群 提交于 2019-12-10 15:36:19
问题 We are planing to build a Rails application which utilizes both LDAP and database authentication ways. we plan to take devise and devise_ldap_authenticatable to accomplish that. The authlogic maybe like this, internal use complete the authentication by LDAP, however, external user have to sign up for the first time, and then app could take the database authentication. I search by google, Devise and devise_ldap_authenticatable can't work in combined way, anybody here has similar usage, or some

pg_dump version mismatch in Rails

时光怂恿深爱的人放手 提交于 2019-12-10 14:53:43
问题 When running the rake db:structure:dump command, I encountered the following error: Larson-2:app larson$ rake db:structure:dump pg_dump: server version: 9.1.3; pg_dump version: 9.0.4 pg_dump: aborting because of server version mismatch rake aborted! Error dumping database How can I go about updating pg_dump? I have pg 9.1.3 installed, is there a way to update the references inside of Rails to the new version? When I try to update postgres via homebrew, I get the following output: Larson-2:app

Capistrano deployment fails after upgrade to Rails 3.2.11

ⅰ亾dé卋堺 提交于 2019-12-10 13:07:09
问题 I have production Rails 3.2.3 application which I use to deploy using capistrano. When I decided to upgrade rails to 3.2.11 i did following steps: changed rails version in Gemfile run "bundle update rails" pushed new gems from vendor/cache, Gemfile and Gemfile.lock run "cap production deploy" Capistrano now fails with error: * 2013-01-11 15:58:25 executing `deploy:assets:precompile' triggering before callbacks for `deploy:assets:precompile' * 2013-01-11 15:58:25 executing `deploy:assets

rails 3.2.3 doesn't work on https using webrick in ubuntu 12.0.4

荒凉一梦 提交于 2019-12-10 13:05:41
问题 Have been trying to get a fresh, just created rails application to work on ssl using webrick in ubuntu 12.0.4. Have tried all possible methods that I'm aware of. Tried using config.force_ssl = true in application.rb , also force_ssl in application controller . For some reasons, when I use https:// loacalhost:3000 on firefox I get an error message saying, ###An error occurred during a connection to localhost:3000.### ###SSL received a record that exceeded the maximum permissible length.### ###

rspec integration test with devise throws NoMethodError error

瘦欲@ 提交于 2019-12-10 13:01:26
问题 I have a similar error posted here, but all will not fix my problem. My file 'spec/request/news_controller_spec.rb' looks like: require 'spec_helper' describe "NewsController" do include Devise::TestHelpers describe "GET /news" do before(:each) do @request.env["devise.mapping"] = Devise.mappings[:user] @user = Factory.create(:user) @user.confirm! sign_in @user end it "after login should show the latest news an screen" do page.should have_content("News") end end end If I run the test I'll get:

Setting Time.zone during a request: Thread Safe?

我怕爱的太早我们不能终老 提交于 2019-12-10 12:48:11
问题 I'd like to let users of my app specify a time zone, and then set their time zone at the beginning of each request. In Rails, AFAICT, this is done by setting the singleton object: Time.zone = "America/Los_Angeles" My understanding of best practices is that, generally speaking, a singleton should be set ONCE. For example in the application configuration. From an answer to a similar question, someone suggests setting it in the ApplicationController class ApplicationController < ActionController

Why does rake db:rollback rollback three steps?

我们两清 提交于 2019-12-10 12:41:44
问题 Normally when I do $ rake db:rollback it rolls back one migration. But now, repeatedly times, it has rollbacked 3 steps. How come this behaviour? I'm on Rails 3.2.13. 回答1: You can specify the number of steps like this: rake db:rollback STEP=3 The STEP parameter is actually an environment variable here. If, in your terminal, you run the command echo $STEP , does it return 3? If it does, you can execute export STEP=1 to get back to expected behaviour. If it happens again, try to find out where