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
155
votes
10 answers

Deleting all records in a database table

How do I delete all records in one of my database tables in a Ruby on Rails app?
Justin Meltzer
  • 13,318
  • 32
  • 117
  • 182
154
votes
6 answers

How to get current path with query string using Capybara

The page url is something like /people?search=name while I used current_path method of capybara it returned /people only. current_path.should == people_path(:search => 'name') But it fails saying expected: "/people?search=name" got: "/people" How…
kriysna
  • 6,118
  • 7
  • 30
  • 30
153
votes
8 answers

Rails: FATAL - Peer authentication failed for user (PG::Error)

I am running my development on Ubuntu 11.10, and RubyMine Here is my development settings for the database.yml: which RubyMine created for me development: adapter: postgresql encoding: unicode database: mydb_development pool: 5 username:…
simo
  • 23,342
  • 38
  • 121
  • 218
153
votes
6 answers

Rails hidden field undefined method 'merge' error

I wanna do something like this in rails Here is what I have so far in rails: <%= form_for @order do |f| %> <%= f.hidden_field :service, "test" %> <%= f.submit %> <% end %> But then I get this error: undefined method `merge' for…
Jake
  • 1,637
  • 2
  • 12
  • 10
153
votes
8 answers

Removing all installed Gems and starting over

I recently started learning Ruby and Ruby on Rails, and have watched a plethora of getting started materials. I have been finding lately that I keep getting errors where gems won't install or they will be installed but they can't be used for some…
Dave Long
  • 9,569
  • 14
  • 59
  • 89
152
votes
15 answers

How do I remove the Devise route to sign up?

I'm using Devise in a Rails 3 app, but in this case, a user must be created by an existing user, who determines what permissions he/she will have. Because of this, I want: To remove the route for users to sign up. To still allow users to edit their…
Nathan Long
  • 122,748
  • 97
  • 336
  • 451
151
votes
7 answers

API Versioning for Rails Routes

I'm trying to version my API like Stripe has. Below is given the latest API version is 2. /api/users returns a 301 to /api/v2/users /api/v1/users returns a 200 of users index at version 1 /api/v3/users returns a 301 to /api/v2/users /api/asdf/users…
maletor
  • 7,072
  • 7
  • 42
  • 63
151
votes
9 answers

No route matches [GET] /assets

I have a Rails app that I'm trying to test in the production environment. I ran RAILS_ENV=production rake assets:precompile which generated all of my assets in /public/assets. The problem is that when I start my app w/ RAILS_ENV=production rails s…
Kyle Decot
  • 20,715
  • 39
  • 142
  • 263
148
votes
7 answers

Lost my schema.rb! Can it be regenerated?

Due to some deployment issues I stopped tracking schema.rb in git. Somehow I have stuffed this up and somewhere along the way my schema.rb file has disappeared. Is there a way of regenerating schema.rb from the database or from the migrations? I…
brad
  • 9,573
  • 12
  • 62
  • 89
148
votes
3 answers

When to use a "has_many :through" relation in Rails?

I am trying to understand what has_many :through is and when to use it (and how). However, I am not getting it. I am reading Beginning Rails 3 and I tried Googling, but I am not able to understand.
LuckyLuke
  • 47,771
  • 85
  • 270
  • 434
146
votes
29 answers

Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432?

Before anything, please note that I have found several similar questions on Stack Overflow and articles all over the web, but none of those helped me fix my issue: PG Error could not connect to server: Connection refused Is the server running on…
145
votes
1 answer

Rails respond_with: how does it work?

I've been reading here and there about how cool the respond_with method is in Rails 3. But I can't even find a reference to it in either the Rails APIs or by searching the source. Can anyone either explain to me how it works (what options you can…
jaydel
  • 14,389
  • 14
  • 62
  • 98
144
votes
9 answers

Strip html from string Ruby on Rails

I'm working with Ruby on Rails, Is there a way to strip html from a string using sanitize or equal method and keep only text inside value attribute on input tag?
Mattias
  • 1,461
  • 2
  • 9
  • 5
142
votes
16 answers

How do I clear stuck/stale Resque workers?

As you can see from the attached image, I've got a couple of workers that seem to be stuck. Those processes shouldn't take longer than a couple of seconds. I'm not sure why they won't clear or how to manually remove them. I'm on Heroku using Resque…
Shpigford
  • 24,748
  • 58
  • 163
  • 252
142
votes
7 answers

Pass ruby script file to rails console

Is there a way to pass ruby file, foo.rb to rails console. Expected results would be after console starts rails environment to run file. Or any other way which would allow me to execute file in rails environment, triggered from command prompt.
Haris Krajina
  • 14,824
  • 12
  • 64
  • 81