Legacy version of the Ruby on Rails web development framework.
Questions tagged [ruby-on-rails-2]
746 questions
2
votes
2 answers
Rails undefined method for array
In my controller I am trying to run a query to get all of the id's not referenced in another table like so:
@vlan_numbers = ActiveRecord::Base.connection.execute("SELECT pop_vlans.id, vlan_number FROM pop_vlans WHERE pop_vlans.id NOT IN (SELECT…

martincarlin87
- 10,848
- 24
- 98
- 145
2
votes
2 answers
Checking for nil value using :before_save
In my view I have a dropdown of people within an organisation that a ticket can be assigned to.
<%= select( "ticket", "assigned_support_id", Person.find_admin_and_support.collect {|p|…

martincarlin87
- 10,848
- 24
- 98
- 145
2
votes
1 answer
Load several ActiveRecord models in one query
My application is on Rails 2.
I have 2 models, joined by a has_and_belongs_to_many relation : Message and Conversation.
So I have 3 tables, messages, conversations and conversations_messages.
Is it possible to load in one unique query both objects…

pierallard
- 3,326
- 3
- 21
- 48
2
votes
1 answer
Using durations as hash keys in Rails
Since I'm dealing quite a lot with durations in my Rails app, I would also like to use them as hash keys in some places. However, it does not seem to work as expected for me.
Creating the initial hash works fine. For example, the following will…

dominos
- 412
- 1
- 11
- 21
2
votes
2 answers
Rails 2 - Absolute of money
How to get absolute value of money?
e.g:
-2.to_money.? = 2.to_money
2.to_money.? = 2.to_money
I have an attribute total_price, which may be positive or negative. I want to calculate the absolute value of total_price.

Swati Sucharita
- 64
- 8
2
votes
1 answer
Problems running rails 2.3.10 bundler `require': no such file to load -- rubygems (LoadError)
I have an app on Rails 2.3.10 on production; when I try to start with ruby script/server -p 3017 -e production -d it throws me the following error:
Rails requires RubyGems >= 1.3.2. Please install RubyGems and try again:…

trejo08
- 2,348
- 1
- 13
- 12
2
votes
0 answers
Return from partial displaying content
I have a partial in Rails.
View:
<%= render :partial => "partial" %>
Partial:
<% if no_entries %>
No entries
<% return %> <% end %> When I run this partial with an error, the output is blank. How can I…
Dan Grahn
- 9,044
- 4
- 37
- 74
2
votes
0 answers
actionmailer, sending mail to outlook group fails
Rails 2.3.18
Sending mail to an Outlook group address is not working.
recipients 'group_address@outlook.com'
This succeeds according to the log, but nothing is seen in any of the address inboxes that make up the group.
However this,
recipients…

cluv
- 620
- 6
- 11
2
votes
1 answer
Why does the Rails.cache.write return a different value in Rails 2.3.11 and Rails 3.2.11 console?
I am trying to expire key in 10 seconds, somehow it is, but not working with rspec. In this process, I noticed Rails.cache.write return false in Rails 2.3.11, while Rails.cache.write return true in Rails 3.2.11, is this a problem? why different…

AMIC MING
- 6,306
- 6
- 46
- 62
2
votes
1 answer
What is the backport of Rails 3 style finders (.where) to Rails 2?
I know I've heard of a library that provides Rails 3 style finders (.where) to earlier versions of Rails, but web search is failing me.
I've got a 2.3 project that needs a new feature, and I'd rather use the newer style in case it gets upgraded.

Justin Love
- 4,397
- 25
- 36
2
votes
2 answers
On Rails, is there a shortcut to check for boolean defined variable and use its value or use a default if not defined?
On Ruby on Rails 3, I am trying to use the value of a boolean variable, if defined, otherwise use default value true. How should I write something like this?
if var.defined?
var
else
true
end
Thanks in advance

p.matsinopoulos
- 7,655
- 6
- 44
- 92
2
votes
1 answer
ActionDispatch::ShowExceptions - rails upgrade 2.3.x to 3.2.x
In my rails2.3.11 app/controllers/application_controller.rb I have this
ActionDispatch::ShowExceptions::rescue_responses["ActionController::RoutingError"] = :not_found
now this feature is deprecated in rails-3.2.11, I am getting this server…

Maria Bussey
- 25
- 5
2
votes
2 answers
Passing html class to option in options_for_select not working Rails 2.3.9
I am working on a Rails 2.3.9 application . I need to pass a class to the options. The way i am doing is
<%= select(:resporg, "hresporg_#{row_id}",options_for_select(["Item11",["Item 2", {:class => 'has-versions'}]]), {}, {:multiple =>…

AnkitG
- 6,438
- 7
- 44
- 72
2
votes
1 answer
undefined method `new' for nil:NilClass error while unzipping using archive-zip in ruby
I am using archive-zip gem for unzipping zip files inside ruby code to be used in a scheduler task.
Some times it is working fine but few times i am getting "undefined method `new' for nil:NilClass" error while unzipping in Archive:zip line.
The…

Orangescrum
- 33
- 4
2
votes
0 answers
Landscape page layout using Rails and Spreadsheet
I'm using Spreadsheet to generate reports in application and I need to set page layout to landscape when file will be printed (customer request).
Is there any way to do this on the application level?

Dariusz Sadowski
- 43
- 5