Legacy version of the Ruby on Rails web development framework.
Questions tagged [ruby-on-rails-2]
746 questions
9
votes
3 answers
How to show sql result on server console
In Rails v2.3 , Ruby 1.8, if I run a sql statement with following code in my model class:
ActiveRecord::Base.connection.execute("select count(*) from cars;")
How can I show the query result in server console?
I tried :
rslt =…

Mellon
- 37,586
- 78
- 186
- 264
9
votes
2 answers
How to set the action with form_for?
I created a new page on an existing controller.
I added 2 action methods on the controller: prompt_user and process_feedback.
So I get to the page via
redirect_to :controller => :users, :action => :prompt_user
And the form_for code looks like
<%…

Timid Developer
- 143
- 1
- 1
- 7
8
votes
1 answer
Throw an exception whenever someone tries to mass-assign protected attributes
I'm fixing some mass assignment vulnerabilities in a client's application and I want to make sure Rails isn't silently dropping attempts to mass assign protected attributes. Instead, I want to throw an exception so I can investigate.
I.e., whenever…

Tom Lehman
- 85,973
- 71
- 200
- 272
7
votes
6 answers
Generate URL for file in /public in Rails 2 ERB view
In my rails (v2.3.8) app I have a static resource file which I've put at /public/myfile.kml No need for any special routes.rb setting right?
It serves up just fine at http://localhost:3000/myfile.kml
When I deploy (to passenger) it appears at…

Harry Wood
- 2,220
- 2
- 24
- 46
6
votes
2 answers
What is the difference between using ? and % when sanitizing fields in ActiveRecord?
I've been puzzled for a while over the difference between using a question mark, e.g.
Foo.find(:all, :conditions => ['bar IN (?)', @dangerous])
and using sprintf style field types, e.g.
Bar.find(:all, :conditions => ['qux IN (%s)', @dangerous])
in…

Alexander Clark
- 763
- 1
- 7
- 15
6
votes
2 answers
5
votes
1 answer
Rails 2.3 and rspec-rails compatability
What version of the rspec-rails gem is still compatible with Rails 2.3 branch (2.3.14 specifically)? I've tried 2.1.0, but that one's also for Rails >= 3.0. Any other dependencies or version limitations that I should be aware of?
Thanks.

sa125
- 28,121
- 38
- 111
- 153
5
votes
2 answers
Flash message showing twice when using redirect_to (Rails 2)
Ok, this is a weird one.
flash[:success] = 'some success message'
redirect_to :controller => 'media', :action => 'index'
The message is being displayed after the redirect, the thing is it also appears one more time after clicking on a link or go to…

mendi
- 85
- 6
5
votes
3 answers
rvmrc file not working
I have created a gemset named rails2ruby192 and i have added below code in my .rvmrc file in root directory but it is not loading the gemset.
ruby-1.9.2-p180@rails2ruby192

persian
- 91
- 1
- 3
5
votes
2 answers
Ruby Net::HTTP - Stop automatically escaping quotes?
I have the following code:
http = Net::HTTP.new("www.something.com", 80)
http.set_debug_output($stdout)
http.post("/blah", "something", {'random-parameter' => 'value1="something",value2="somethingelse"'})
Then when I read the output…

n s
- 1,361
- 2
- 12
- 24
5
votes
1 answer
What happen if i use ruby version 2.5.1 with rails version 2.3.18?
What happen if i use ruby version 2.5.1 with rails version 2.3.18 ?
I had rails application built on rails 2.3.18 and ruby 1.9.2p320,
I want to upgrade version of ruby only not the rails is it possible ?
What are the challenges i have to face with…

dr. strange
- 665
- 7
- 22
5
votes
3 answers
Rails - How do I use application.html.erb in my custom layout?
I have a Controller called "Pages" with around 5 pages (views) for which I have rendered a layout called "page.html.erb".
So my "Pages" Controller has:
class PagesController < ApplicationController
layout 'page'
I want my "page.html.erb" layout…

Supritha
- 51
- 1
- 6
5
votes
5 answers
Rails render partial in a loop
I am new to rails and I am trying to render a partial within a loop as such.
Here , books is an array eager loaded in controller.
books.each do |book|
<%= render 'books/book', :book => book %>
end
This works fine. But when the books array is…

testsum
- 51
- 1
- 2
5
votes
1 answer
Rails legacy app and Ruby 2 error: can not load translations from the file type yml is not known
I have a legacy Rails application which I want to upgrade to recent Rails and Ruby versions.To start with I am trying to setup the application with Ruby 2.1.2
$ rails -v
Rails 2.3.18
$ ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877)…

Jignesh Gohel
- 6,236
- 6
- 53
- 89
5
votes
3 answers
How can I iterate through an array in rails view?
I did a query in MySql but is working in Rails and mysql2 gem.
Here is the information:
http://sqlfiddle.com/#!2/9adb8/6
The query is working fine without problems and showing this result:
UNIT V1 A1 N1 V2 A2 N2 V3 A3 N3 V4 A4 N4 …

Carlos Morales
- 1,137
- 3
- 15
- 38