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
38
votes
1 answer

Is it advisable to include the contents of vendor/cache in Git in a Rails 3.2 application?

I frequently need to create branches in my application for new development. This often means that I have changes to my Gemfile in my branch that are not present in Master, and as such I end up with differences in the cached gems in vendor/cache. I…
RubyRedGrapefruit
  • 12,066
  • 16
  • 92
  • 193
38
votes
11 answers

How to make a check_box checked in rails?

I made checkboxes using the following rails form helper: <%= check_box("tag", tag.id) %> However, I need to make some of them checked by default. The rails documentation doesn't specify how to do this. Is there a way? How?
36
votes
6 answers

Use active_model_serializer with a non-ActiveRecord object

I have a model object that is not descended from ActiveRecord::Base and is not stored in the database. I created a serializer for it (with the same name + "Serializer"), and in my controller I'm calling render json: object_instance. The result is an…
Robin Daugherty
  • 7,115
  • 4
  • 45
  • 59
36
votes
6 answers

strong parameters permit all attributes for nested attributes

Is there a way in strong parameters to permit all attributes of a nested_attributes model? Here is a sample code. class Lever < ActiveRecord::Base has_one :lever_benefit accepts_nested_attributes_for :lever_benefit end class LeverBenefit <…
35
votes
5 answers

rake assets:precompile RAILS_ENV=production not working as required

I am trying to precompile assets using the command rake assets:precompile RAILS_ENV=production, but I always get the error below. ** Invoke assets:precompile (first_time) ** Execute assets:precompile /usr/bin/ruby /usr/bin/rake…
35
votes
10 answers

what is the difference between link_to, redirect_to, and render?

I am confused about the main difference(s) among link_to, redirect_to and render in Rails. anyone can please explain.
35
votes
10 answers

ERROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' (available in RDoc 2.4.2+) instead

Seems the last post for this problem was closed for one reason or another so I'll try my luck... I'm trying to run a simple "rake db:migrate" command. When I do, I get the error in the title. Yes, the solution "appears" obvious but it's not because…
DaveR
  • 1,295
  • 1
  • 13
  • 35
35
votes
14 answers

Seeding users with Devise in Ruby on Rails

In my development and test environments, I want to seed the database with a bunch of users. I'm using Ruby on Rails v3.2.8 and the latest Devise. So I added this line in my db/seeds.rb file: User.create(email: 'test@example.com',…
at.
  • 50,922
  • 104
  • 292
  • 461
34
votes
8 answers

How to save a model without running callbacks in Rails

I need to calculate values when saving a model in Rails. So I call calculate_averages as a callback for a Survey class: before_save :calculate_averages However, occasionally (and initially I have 10k records that need this operation) I need to…
34
votes
2 answers

Rails - How to test that ActionMailer sent a specific attachment?

In my ActionMailer::TestCase test, I'm expecting: @expected.to = BuyadsproMailer.group_to(campaign.agency.users) @expected.subject = "You submitted #{offer_log.total} worth of offers for #{offer_log.campaign.name} " @expected.from = "BuyAds…
33
votes
3 answers

Sending files to a Rails JSON API

I know there are questions similar to this one, but I've not found a good answer yet. What I need to do is send a description of an object to one of my create methods, which includes some different attributes including one called :image, a paperclip…
Emil Ahlbäck
  • 6,085
  • 8
  • 39
  • 54
33
votes
5 answers

How to create a Ruby DateTime from existing Time.zone for Rails?

I have users entering in dates in a Ruby on Rails website. I parse the dates into a DateTime object with something like: date = DateTime.new(params[:year].to_i, params[:month].to_i, params[:day].to_i, params[:hour].to_i,…
at.
  • 50,922
  • 104
  • 292
  • 461
32
votes
5 answers

How to use Eclipse for Ruby on Rails (RoR)

I am new in Ruby. I have installed Ruby on Rails on Windows 7. I visited the following to choose a suitable IDE/Editor for writing Ruby code: http://rubyonrails.org/download I found the following Editors for Ruby: VIM for Rails, RadRails, RubyMine,…
Ripon Al Wasim
  • 36,924
  • 42
  • 155
  • 176
31
votes
4 answers

Rails database defaults and model validation for boolean fields

In a Rails model I have an attribute is_subscriber, when I constructed a db migration to add this column to the database I specified the default value to be false: t.boolean "is_subscriber", :default => false I also specified in the model that…
Andrew Lauer Barinov
  • 5,694
  • 10
  • 59
  • 83
30
votes
4 answers

Set maximum length in Text field in RoR

Has anyone managed to set maximum field lenghts for text fields How can i set the maximum length of a text field. Here is the code iam using <%= text_field_tag(:create_text), :input_html => {:maxlength => 15, :size => 40} %> but I cannot seem to…