Questions tagged [ruby-on-rails-3.2]

Ruby on Rails version 3.2.0 released at January 20, 2012. Use this tag for issues related to development in Ruby on Rails version 3.2.0.

Ruby on Rails version 3.2.0 is a specific version of Ruby on Rails. Released on January 20th, 2012. It has been succeeded by version 3.2.15. It brings many improvements to the Ruby on Rails web development framework.

The distinct features include:

  • Faster development mode: only modified classes are reloaded giving a visible performance boost.
  • Automatic Query Explanation: database queries taking longer than 30 seconds to execute are automatically explained while in development mode.

Further reading:

Related tag

6982 questions
64
votes
7 answers

Using send_file to download a file from Amazon S3?

I have a download link in my app from which users should be able to download files which are stored on s3. These files will be publicly accessible on urls which look something like https://s3.amazonaws.com/:bucket_name/:path/:to/:file.png The…
David Tuite
  • 22,258
  • 25
  • 106
  • 176
63
votes
14 answers

Rails: How to set a background image in rails from css?

I am using rails 3.2 and i have to set a background for one of the page and i have tried many ways and nothing went right, so looking for some good help. I have tried background: url(<%= asset_path 'background.jpg' %>) background:…
63
votes
4 answers

rails generate model

I'm trying to follow instructions from the book "Head First Rails" and on page 50 it says to create a model but I am unable to create a model using the rails command. When I type this at this prompt: localhost:~ home$ rails generate model ad…
Livi17
  • 1,620
  • 3
  • 25
  • 43
59
votes
1 answer

What is the difference between Rails.cache.clear and rake tmp:cache:clear?

Are the two commands equivalent? If not, what's the difference?
Crashalot
  • 33,605
  • 61
  • 269
  • 439
57
votes
5 answers

Rails: How to use dependent: :destroy in rails?

I have 2 models as describes below. class EmpGroup < ActiveRecord::Base belongs_to :user has_many :emp_group_members, dependent: :destroy end and class EmpGroupMember < ActiveRecord::Base belongs_to :emp_group belongs_to :user end now the…
56
votes
2 answers

Model.reset_column_information does not reload columns in rails migration

I'm using Rails 3.2 and have a migration that contains the code: add_column :users, :gift_aid, :integer, :default => 2 # reset columns User.reset_column_information ... code here to load legacy data from sqlite3 database ... # now create a user…
Iain
  • 942
  • 1
  • 8
  • 10
54
votes
4 answers

Possible to alias a belongs_to association in Rails?

I have a model with a belongs_to association: class Car < ActiveRecord::Base belongs_to :vendor end So I can call car.vendor. But I also want to call car.company! So, I have the following: class Car < ActiveRecord::Base belongs_to :vendor def…
at.
  • 50,922
  • 104
  • 292
  • 461
52
votes
7 answers

Rails routes: GET without param :id

I'm developing a REST API based on rails. To use this API, you MUST be logged in. Regarding that, I'd like to create a method me in my user controller that will return a JSON of the logged in user infos. So, I don't need an :id to be passed in the…
Gozup
  • 1,005
  • 2
  • 10
  • 20
51
votes
2 answers

ruby on rails how to deal with NaN

I have read few posts regarding NaN but did not figure out how to deal with it in Ruby on Rails. I want to check a value if it is a NaN I want to replace it with Zero(0). I tried the following logger.info(".is_a? Fixnum #{percent.is_a?…
49
votes
6 answers

haml by default

Is there a way to configure rails to use haml by default, i.e. when a scaffold is generated the according scaffold_name/index.html.haml is generated instead of scaffold_name/index.html.erb. Similar to how you are able to add…
rudolph9
  • 8,021
  • 9
  • 50
  • 80
48
votes
28 answers

Factory already registered: user (FactoryGirl::DuplicateDefinitionError)

Description of problem: - I've setup factory_girl_rails however whenever I try and load a factory it's trying to load it multiple times. Environment: - rails (3.2.1) - factory_girl (2.5.2) - factory_girl_rails (1.6.0) - ruby-1.9.3-p0 [ x86_64 ] >…
user1212241
  • 506
  • 1
  • 4
  • 6
46
votes
7 answers

POSTing raw JSON data with Rails 3.2.11 and RSpec

In order to ensure that my application is not vulnerable to this exploit, I am trying to create a controller test in RSpec to cover it. In order to do so, I need to be able to post raw JSON, but I haven't seemed to find a way to do that. In doing…
Daniel Vandersluis
  • 91,582
  • 23
  • 169
  • 153
45
votes
7 answers

Using turbolinks in a Rails link_to

Just wondering whether there's a way to use turbolinks directly in a rails link_to helper, a quick bit of googling didn't uncover anything of note, here's the type of thing I've tried to no avail. <%= link_to 'Giraffe', giraffe_path(@giraffe),…
Gareth Jones
  • 1,760
  • 1
  • 14
  • 24
43
votes
10 answers

rails confirm before delete

Here is my rails link_to <%= link_to 'Delete',url_for(action: :delete,id: @user.id),data: {confirm: "Are you sure?"} %> I tried the above method but it is directly deleting without any alert message. What wrong I made. Can any one correct it.
Prabhakaran
  • 3,900
  • 15
  • 46
  • 113
43
votes
3 answers

How to debug a Rails asset precompile which is unbearably slow

I'm working on a Rails 3.2 project and the assets have increased a fair bit in recent months although I wouldn't consider the project to be large. The assets consist of JS (no coffee-script), and SASS files; we've quite a few images but they've been…
andyroberts
  • 3,458
  • 2
  • 37
  • 40