ruby-on-rails-2

mysql2.so: libmysqlclient_r.so.15: cannot open shared object file: No such file or directory

二次信任 提交于 2019-11-27 01:48:12
问题 I am trying to run a Rails two app with Ubuntu 10.04 server, sphinx, myql2 version 0.2.7 and percona server 5.5 (Myslql 5.5). mysql2 in irb works ok, I can connect to the db. this rails 2 app is working in another Centos server with MySql 5.1. When I run: script/server -e production I get: mysql2.so: libmysqlclient_r.so.15: cannot open shared object file: No such file or directory here are the libs I have: # ls -l /usr/lib |grep sql -rw-r--r-- 1 root root 10581008 2011-11-18 16:51

Rails 2: Model.find(1) gives ActiveRecord error when id 1 does not exist

不羁的心 提交于 2019-11-26 22:38:53
I am using Rails 2.3.5 and in that if I give Model.find(1) and if 1 is not in the database, it returns ActiveRecord error. Should it just be returning nil as in the case of Model.find_by_column('..') ? This is the expected behavior. I think David explains this the best himself, so here is a quote from Ruby, S., Thomas, D. & Hansson, D.H., 2009. Agile Web Development with Rails , Third Edition Third Edition., Pragmatic Bookshelf (p.330). When you use a finder driven by primary keys, you’re looking for a particular record. You expect it to exist. A call to Person.find(5) is based on our

undefined method `source_index' for Gem:Module (NoMethodError)

末鹿安然 提交于 2019-11-26 18:45:18
问题 I'm running a Rails 2.3.5 application and upon running script/server I am shown the following: ./script/../config/../vendor/rails/railties/lib/rails/gem_dependency.rb:21:in `add_frozen_gem_path': undefined method `source_index' for Gem:Module (NoMethodError) from ./script/../config/boot.rb:60:in `load_initializer' from ./script/../config/boot.rb:44:in `run' from ./script/../config/boot.rb:17:in `boot!' from ./script/../config/boot.rb:123 from script/server:2:in `require' from script/server:2

Force SSL using ssl_requirement in Rails 2 app

馋奶兔 提交于 2019-11-26 16:15:25
问题 I have a Rails application which need to run under SSL. I tried ssl_requirement but seems I have to type in all the actions in every controllers. Is there any method that I can add a before_filter in application controller with ssl_requirement, so that the apps will redirect to https automatically when user request is in http? Thanks all. :) 回答1: Use a Rack Middleware. # lib/force_ssl.rb class ForceSSL def initialize(app) @app = app end def call(env) if env['HTTPS'] == 'on' || env['HTTP_X

Upgrading from Rails 2.3.8 to 4.0

℡╲_俬逩灬. 提交于 2019-11-26 15:29:05
问题 I am running an application on Rails 2.3.8. I am planning to upgrade it to Rails 4.0 (which is in RC). What will be the easiest way for me to do this? Do I need to first upgrade to Rails 3.x? Note: in my current implementation, I am using starling and ferret; as part of upgrade I am also considering to move to sidekiq and sunspot 回答1: This is a multi-step process, and depending on the size of your application, it can take a long time. At each step, you'll want to test your application for

ActiveRecord::Base Without Table

不想你离开。 提交于 2019-11-26 12:09:37
问题 This came up a bit ago ( rails model attributes without corresponding column in db ) but it looks like the Rails plugin mentioned is not maintained ( http://agilewebdevelopment.com/plugins/activerecord_base_without_table ). Is there no way to do this with ActiveRecord as is? If not, is there any way to get ActiveRecord validation rules without using ActiveRecord? ActiveRecord wants the table to exist, of course. 回答1: This is an approach I have used in the past: In app/models/tableless.rb

Rails ActiveRecord date between

不羁的心 提交于 2019-11-26 03:14:57
I need to query comments made in one day. The field is part of the standard timestamps, is created_at . The selected date is coming from a date_select . How can I use ActiveRecord to do that? I need something like: "SELECT * FROM comments WHERE created_at BETWEEN '2010-02-03 00:00:00' AND '2010-02-03 23:59:59'" ndbroadbent Just a note that the currently accepted answer is deprecated in Rails 3. You should do this instead: Comment.where(:created_at => @selected_date.beginning_of_day..@selected_date.end_of_day) Or, if you want to or have to use pure string conditions , you can do: Comment.where(

Rails ActiveRecord date between

岁酱吖の 提交于 2019-11-26 01:12:55
问题 I need to query comments made in one day. The field is part of the standard timestamps, is created_at . The selected date is coming from a date_select . How can I use ActiveRecord to do that? I need something like: \"SELECT * FROM comments WHERE created_at BETWEEN \'2010-02-03 00:00:00\' AND \'2010-02-03 23:59:59\'\" 回答1: Just a note that the currently accepted answer is deprecated in Rails 3. You should do this instead: Comment.where(:created_at => @selected_date.beginning_of_day..@selected