Questions tagged [ruby-on-rails-3]

Ruby on Rails is an open-source web development framework written in Ruby. Ruby on Rails follows the principle of convention over configuration, freeing you from having to re-invent things to stay productive. Use this tag only for Rails 3-specific questions, and also tag those questions [ruby-on-rails].

Ruby on Rails 3.0 was a major revision of Ruby on Rails in 2010, the open-source web development framework designed to make programmers happy and productive. Rails 3.0 brings a bunch of new features and improvements over older Rails versions, including:

  • Brand new router with an emphasis on RESTful declarations
  • New Active Record chainable query language built on top of relational algebra
  • Unobtrusive JavaScript helpers with drivers for Prototype, jQuery
  • Explicit dependency management with Bundler

See Ruby on Rails 3.0 Release Notes for more information.

Multiple sub-versions have been released, namely 3.0, 3.1 and 3.2. Questions regarding specific sub-versions of Ruby on Rails 3.0 can also be asked on the appropriate tags:

Resources:

See also:

56082 questions
105
votes
6 answers

Using Rails link_to for links that post

I have a link that I need to submit a post request with. Normally, I'd use jQuery and prevent the link's default behavior and then submit a form to the destination. This seems like something Rails should be able to help me out with. Sure enough, the…
at.
  • 50,922
  • 104
  • 292
  • 461
104
votes
12 answers

Rails: Order with nulls last

In my Rails app I've run into an issue a couple times that I'd like to know how other people solve: I have certain records where a value is optional, so some records have a value and some are null for that column. If I order by that column on some…
Andrew
  • 42,517
  • 51
  • 181
  • 281
104
votes
9 answers

Capybara Ambiguity Resolution

How do I resolve ambiguity in Capybara? For some reason I need links with the same values in a page but I can't create a test since I get the error Failure/Error: click_link("#tag1") Capybara::Ambiguous: Ambiguous match, found 2 elements…
neilmarion
  • 2,372
  • 7
  • 21
  • 36
103
votes
6 answers

Rails: How to get the model class name based on the controller class name?

class HouseBuyersController < ... def my_method # How could I get here the relevant model name, i.e. "HouseBuyer" ? end end
Misha Moroshko
  • 166,356
  • 226
  • 505
  • 746
103
votes
12 answers

Net::SMTPAuthenticationError when sending email from Rails app (on staging environment)

I am sending email from my Rails application. It works well on development environment, but fails on staging. I get the following error: Net::SMTPAuthenticationError (534-5.7.14…
eagor
  • 9,150
  • 8
  • 47
  • 50
102
votes
5 answers

How to fix the uninitialized constant Rake::DSL problem on Heroku?

I am getting errors similar to the ones in these questions, except mine are occuring on Heroku: 2011-05-30T09:03:29+00:00 heroku[worker.1]: Starting process with command: `rake jobs:work` 2011-05-30T09:03:30+00:00 app[worker.1]: (in…
ben
  • 29,229
  • 42
  • 124
  • 179
102
votes
6 answers

Convert UTC to local time in Rails 3

I'm having trouble converting a UTC Time or TimeWithZone to local time in Rails 3. Say moment is some Time variable in UTC (e.g. moment = Time.now.utc). How do I convert moment to my time zone, taking care of DST (i.e. using EST/EDT)? More…
Marc-André Lafortune
  • 78,216
  • 16
  • 166
  • 166
102
votes
8 answers

What is the best way to uninstall gems from a rails3 project?

I installed all of my gems using bundler via the Gemfile. I thought (mistakenly) that if I deleted a gem from my Gemfile and ran 'bundle install' that the deleted gems would be uninstalled. I've looked at the bundler help file and, so far as I can…
lashleigh
  • 2,555
  • 2
  • 20
  • 28
101
votes
3 answers

Path helpers generate paths with dots instead of slashes

In my routes.rb I have the following: resources :message_threads When I call: message_threads_path(1) I get: /message_threads.1 Why is this? My other resources work fine. Am I not pluralizing this correctly or something?
ghempton
  • 7,777
  • 7
  • 48
  • 53
101
votes
8 answers

Check if record exists from controller in Rails

In my app a User can create a Business. When they trigger the index action in my BusinessesController I want to check if a Business is related to the current_user.id: If yes: display the business. If no: redirect to the new action. I was trying…
user470763
101
votes
5 answers

Rails auto-assigning id that already exists

I create a new record like so: truck = Truck.create(:name=>name, :user_id=>2) My database currently has several thousand entities for truck, but I assigned the id's to several of them, in a way that left some id's available. So what's happening is…
D-Nice
  • 4,772
  • 14
  • 52
  • 86
101
votes
2 answers

Rails Migration to make a column null => true

I had originally created a table with column as t.string "email", :default => "", :null => false The requirement has changed and now I need to allow email to be null. How can I write a migration to make :null => true
Pykih
  • 2,769
  • 3
  • 29
  • 38
100
votes
6 answers

How to get rspec-2 to give the full trace associated with a test failure?

Right now if I run my test suite using rake spec I get an error: 1) SegmentsController GET 'index' should work Failure/Error: get 'index' undefined method `locale' for # # ./spec/controllers/segments_controller_spec.rb:14: in `block…
marcgg
  • 65,020
  • 52
  • 178
  • 231
100
votes
7 answers

Remove ActiveRecord in Rails 3

Now that Rails 3 beta is out, I thought I'd have a look at rewriting an app I have just started work on in Rails 3 beta, both to get a feel for it and get a bit of a head-start. The app uses MongoDB and MongoMapper for all of its models and…
Mark Embling
  • 12,605
  • 8
  • 39
  • 53
99
votes
6 answers

Share database between 2 apps in Heroku

I want to access the database of an app from another Heroku app. Is that possible in the shared database?
donald
  • 23,587
  • 42
  • 142
  • 223