Legacy version of the Ruby on Rails web development framework.
Questions tagged [ruby-on-rails-2]
739 questions
184
votes
11 answers
Rails ActiveRecord date between
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…
![](../../users/profiles/87610.webp)
rtacconi
- 12,528
- 19
- 64
- 83
132
votes
5 answers
undefined method `source_index' for Gem:Module (NoMethodError)
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…
![](../../users/profiles/1978776.webp)
noodleboy347
- 1,345
- 2
- 9
- 8
67
votes
1 answer
Routing with an optional parameter
I added in the route file:
map.show_book "/show_book/:name/year/:year", :controller => "book", :action => "show_version"
I also added:
map.show_book "/show_book/:name", :controller => "book", :action => "show_version"
to show the latest book…
![](../../users/profiles/179438.webp)
Alessandro De Simone
- 3,692
- 6
- 26
- 37
65
votes
2 answers
Failing to access environment variables within `database.yml` file
I have the following developement section of my development.yml file:
development:
adapter: postgresql
host: localhost
database: testtb
username: app_user
password: ENV['APP_USER_POSTGRES_PASSWORD'] <= Troublesome line
When I open a…
![](../../users/profiles/249543.webp)
jefflunt
- 32,075
- 7
- 80
- 122
52
votes
5 answers
How I can check if an object is null in ruby on rails 2?
I want to check when my object @objectname is not equal to null to show the values of the @objectname else to show that no values found.
I tried this:
<% if (@objectname != null) then %>
but I'm getting an error.
![](../../users/profiles/669711.webp)
George Panayi
- 1,640
- 6
- 26
- 38
31
votes
8 answers
Rails 2: Model.find(1) gives ActiveRecord error when id 1 does not exist
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('..')?
![](../../users/profiles/584440.webp)
rubyprince
- 16,675
- 10
- 57
- 97
30
votes
5 answers
Rails Flash.now not working
I have a view from which I make an ajax request to the controller and after the action is successfully completed I initialize the flash.now[:notice]. But after the control goes back to the view. I don't happen to see the flash…
![](../../users/profiles/765581.webp)
Manjunath Manoharan
- 4,309
- 5
- 24
- 41
29
votes
3 answers
How do you clear a single entry from a ruby on rails session?
In ruby on rails when doing session[:foo] = nil it leaves an entry named :foo in the session object. How can you get rid of that single entry from the session object?
![](../../users/profiles/63828.webp)
Jim Soho
- 1,930
- 2
- 20
- 25
27
votes
7 answers
mysql2.so: libmysqlclient_r.so.15: cannot open shared object file: No such file or directory
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…
![](../../users/profiles/87610.webp)
rtacconi
- 12,528
- 19
- 64
- 83
25
votes
8 answers
Rails: get #beginning_of_day in time zone
I have a default time zone setup for the rails application.
And an instance of the Date object.
How can I get make Date#beginning_of_day to return the beginning of the day in the specified time zone, but not my local timezone.
Is there any other…
![](../../users/profiles/91610.webp)
Bogdan Gusiev
- 7,447
- 14
- 59
- 76
23
votes
7 answers
ActiveRecord::Base Without Table
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…
![](../../users/profiles/8047.webp)
Dan Rosenstark
- 64,546
- 54
- 267
- 405
21
votes
2 answers
Upgrading from Rails 2.3.8 to 4.0
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…
![](../../users/profiles/1129653.webp)
nit
- 311
- 2
- 4
20
votes
5 answers
ActiveRecord Count to count rows returned by group by in Rails
I looked around and couldn't find any answers to this. All answers involved counts that did not use a GROUP BY.
Background:
I have a paginator that will take options for an ActiveRecord.find. It adds a :limit and :offset option and performs the…
![](../../users/profiles/394105.webp)
J.Melo
- 311
- 1
- 3
- 9
20
votes
3 answers
Force SSL using ssl_requirement in Rails 2 app
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…
![](../../users/profiles/314325.webp)
Victor Lam
- 3,446
- 8
- 29
- 42
19
votes
6 answers
How to monkey-patch code that gets auto-loaded in Rails?
I'm monkey-patching a Rails engine with something like:
SomeClass.class_eval do
# ...
end
The first time I hit the web site, on development mode at least, it works, but the second time it's like my patch never existed. I presume it's Rails…
![](../../users/profiles/6068.webp)
pupeno
- 256,034
- 114
- 324
- 541