Legacy version of the Ruby on Rails web development framework.
Questions tagged [ruby-on-rails-2]
746 questions
17
votes
6 answers
A copy of ApplicationController has been removed from the module tree but is still active
Whenever two concurrent HTTP requests go to my Rails app, the second always returns the following error:
A copy of ApplicationController has been removed from the module tree but is still active!
From there it gives an unhelpful stack trace to the…

Matchu
- 83,922
- 18
- 153
- 160
17
votes
1 answer
alias_method on ActiveRecord::Base results in NameError
I have a model inheriting directly from ActiveResource::Base, and I'm trying to run alias_method for most of the columns in the record's table, but the result is a NameError:
NameError: undefined method address_line_1' for class
…

JellicleCat
- 28,480
- 24
- 109
- 162
16
votes
2 answers
How to Install PCRE Development Headers on Mac OSX
I just upgraded my MacBook Pro to Mavericks and my local Ruby on Rails development environment isn't running straight off the bat, when I visit localhost I see It works! and remembered I needed to start Phusion Passenger, so when I run passenger…

martincarlin87
- 10,848
- 24
- 98
- 145
15
votes
1 answer
Adding extra run-time attribs to an activerecord object
I have an Agent model which gets its attributes from the underlying database table. However for one particular controller action I would like to add some 'temporary' attributes to the Agent records before passing them on to the view.
Is this…

nexar
- 11,126
- 3
- 29
- 32
15
votes
5 answers
How can I update attributes in after_save without causing a recursion in rails 2.3?
I've got a model which has a video attached with Paperclip. After it saves I use the saved video to generate a thumbnail. I need to do this after every save, even when a new video hasn't been uploaded, because the user can change the time where the…

peterjwest
- 4,294
- 2
- 33
- 46
15
votes
4 answers
How to change a reference column to be polymorphic?
My model (Bar) already has a reference column, let's call it foo_id and now I need to change foo_id to fooable_id and make it polymorphic.
I figure I have two options:
Create new reference column fooable which is polymorphic and migrate the ID's…

deiga
- 1,587
- 1
- 13
- 32
14
votes
3 answers
application wide global variable
In Rails, where should I define the variable which can be recognized by every layer of Rails stacks.
For example, I would like to have a CUSTOMER_NAME='John' variable which can be accessed in helper, rake task, controller and model. Where should I…

Mellon
- 37,586
- 78
- 186
- 264
14
votes
5 answers
Why does Rails not refresh classes on every request (despite configuration)?
I recently started having to restart my development server every time I change my code. My development.rb file still has this line:
config.cache_classes = false
I tried using the debugger verify that this value has stuck around. To do this I set my…

muirbot
- 2,061
- 1
- 20
- 29
12
votes
2 answers
Undefined method `name' for "SystemTimer":String
I am having a problem getting an old Ruby on Rails 2 app that hasn't worked in a year to work.
I'm trying to run rake test:functionals in the root of my project directory, but am getting undefined method 'name' for "SystemTimer":String.
I've pasted…

sneilan
- 1,367
- 1
- 10
- 15
12
votes
4 answers
Display a checkbox list instead of multiple select
I have a model MyModel with a serialized attribute a, describing an array of symbols.
This code works :
<% form_for @my_model do |f| %>
<%= f.select :a, MyModel::AS, :multiple => true) %>
<% end %>
The parameters are correct :
{ :my_model => { :a…

pierallard
- 3,326
- 3
- 21
- 48
11
votes
5 answers
How to debug Rails I18N lookup?
In the Rails docs there seem to be different default locations for I18N strings, depending if the I18N-lookup was initiated from a view, model / validation, controller, helper, ..., if it's a label, etc...
How can I see where Rails is trying to…
user985823
10
votes
4 answers
expected Hash (got Array) for param 'samples'
I have been following Railscasts episodes of Nested forms and complex forms. During the time of creating multiple model in a single form I was able to edit, update, delete and create records for sample models that were nested in the Batch model.
I…

A1aks
- 187
- 1
- 2
- 15
10
votes
4 answers
Polymorphic Assocations using Integer ID type fields
I have a table Foo that has a polymorphic belongs_to association called bar. The foos table has the standard bar_id column. However, instead of a string-based bar_type column, I have an integer bar_type_id column. This column references the id…

Craig Walker
- 49,871
- 54
- 152
- 212
10
votes
2 answers
Single Table Inheritance and 'type' value for namespaced classes
While working on Rails 2.3.18 to Rails 3.2.x migration I am facing name issue in type column
Here is the relation that is defined.
app/models/reservation.rb
class Reservation
end
class Reservation::Guest < Reservation
end
class Reservation::Event…

Amit Patel
- 15,609
- 18
- 68
- 106
10
votes
5 answers
Rspec - Check if an array have same elements than other, regardless of the order
I'm not sure if its a Rspec question, but I only encountred this problem on Rspec tests.
I want to check if an array is equal to another array, regardless of the elements order :
[:b, :a, :c] =?= [:a, :b, :c]
My current version…

pierallard
- 3,326
- 3
- 21
- 48