Questions tagged [ruby-on-rails-3.1]

Ruby on Rails version 3.1.0 is a specific version of Ruby on Rails. It was released on August 30th, 2011. Use this tag for issues related to development in Ruby on Rails version 3.1.

Ruby on Rails version 3.1.0 is a specific version of Ruby on Rails.

Released on August 30th, 2011, it was succeeded by version 3.2.0.

It brings many improvements to the Ruby on Rails web development framework, which is open-source and optimized for programmer happiness and maintaining sustainable productivity. Many things are defined by convention, freeing you from having to re-invent things to stay productive.

Version 3.1 brings many improvements over its preceding version 2, including faster ActiveRecord, assets re-structure, coffeescript, sass, and more.

Further Reading:

Related tag

5270 questions
416
votes
18 answers

ExecJS and could not find a JavaScript runtime

I'm trying to use the Mongoid / Devise Rails 3.1 template (Mongoid and Devise), and I keep getting an error stating ExecJS cannot find a JavaScript runtime. Fair enough when I didn't have any installed, but I've tried installing Node.js, Mustang…
srboisvert
  • 12,679
  • 15
  • 63
  • 87
389
votes
29 answers

Using Rails 3.1, where do you put your "page specific" JavaScript code?

To my understanding, all of your JavaScript gets merged into 1 file. Rails does this by default when it adds //= require_tree . to the bottom of your application.js manifest file. This sounds like a real life-saver, but I am a little concerned…
266
votes
13 answers

Rails - Could not find a JavaScript runtime?

I created a new Rails project using rails 3.1.0.rc4 on my local machine but when I try to start the server I get: Could not find a JavaScript runtime. See here for a list of available runtimes. (ExecJS::RuntimeUnavailable) Note: This is not about…
200
votes
20 answers

execJs: 'Could not find a JavaScript runtime' but execjs AND therubyracer are in Gemfile

I'm getting this error: rake aborted! Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs, I have already spent more hours searching google then I am willing to admit. I believe this is an execJs bug. From all the…
186
votes
22 answers

Library not loaded: /usr/local/lib/libpq.5.4.dylib

I am working on a rails app. Installed Postgresql using postgresql-9.1.2-1-osx.dmg Installed pg gem. Then when I executed rake db:create getting the following error…
Sathish
  • 4,446
  • 3
  • 22
  • 17
167
votes
3 answers

Using Rails 3.1 assets pipeline to conditionally use certain css

I’m in the process of building my first solo Rails app using Rails 3.1.rc5. My problem is that I want to have my site render the various CSS files conditionally. I’m using Blueprint CSS and I’m trying to have sprockets/rails render screen.css most…
talon55
  • 2,023
  • 3
  • 15
  • 10
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
121
votes
5 answers

Rails 3.1: Engine vs. Mountable App

Can someone help me understand the differences between a Rails Engine and a Mountable app? In Rails 3.1, you can create either one with the "rails new plugin ___" command. rails plugin new forum --full # Engine rails plugin new forum…
110
votes
14 answers

Find number of months between two Dates in Ruby on Rails

I have two Ruby on Rails DateTime objects. How to find the number of months between them? (Keeping in mind they might belong to different years)
phoenixwizard
  • 5,079
  • 7
  • 27
  • 38
103
votes
9 answers

Ruby on Rails: How can I revert a migration with rake db:migrate?

After installing devise MODEL User i got this. class DeviseCreateUsers < ActiveRecord::Migration def self.up create_table(:users) do |t| t.database_authenticatable :null => false t.recoverable t.rememberable …
cola
  • 12,198
  • 36
  • 105
  • 165
102
votes
7 answers

How to set up factory in FactoryBot with has_many association

Can someone tell me if I'm just going about the setup the wrong way? I have the following models that have has_many.through associations: class Listing < ActiveRecord::Base attr_accessible ... has_many :listing_features has_many :features,…
Tonys
  • 3,349
  • 4
  • 24
  • 27
97
votes
5 answers

Rails: How to find_by a field containing a certain string

I have a model named Topic, that has a name as a field. So say I have a term I'm searching for, apple. If I do a Topic.find_by_name("apple") I get a record back with the name apple. That's good -- but how do I change find_by_name so that it can…
varatis
  • 14,494
  • 23
  • 71
  • 114
97
votes
2 answers

Changing a column type to longer strings in rails

At the first migration, I declared on a column content to be string Activerecord made it to be string(255) according to annotate gem. After I push the app to heroku, which uses postgres, if I enter in the form in content a string longer than 255 I…
86
votes
5 answers

Subqueries in activerecord

With SQL I can easily do sub-queries like this User.where(:id => Account.where(..).select(:user_id)) This produces: SELECT * FROM users WHERE id IN (SELECT user_id FROM accounts WHERE ..) How can I do this using rails' 3 activerecord/ arel/…
gucki
  • 4,582
  • 7
  • 44
  • 56
84
votes
9 answers

Run migrations from rails console

Is there a way to run rake commands for db:migrate and db:rollback on the console? It sucks to wait for the rails environment to load!
rafamvc
  • 8,227
  • 6
  • 31
  • 34
1
2 3
99 100