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
60
votes
7 answers

Speed up assets:precompile with Rails 3.1/3.2 Capistrano deployment

My deployments are slow, they take at least 3 minutes. The slow Capistrano task during deploy is assets:precompile. This takes probably 99% of the total deploy time. How can I speed this up? Should I precompile my assets on my local machine and add…
Godisemo
  • 1,813
  • 2
  • 18
  • 26
60
votes
3 answers

What does require_self mean?

In rails3.1 application.css we could see /* *= require_self *= require_tree . */ I know that require_tree . is just telling the system to bundle together everything from the stylesheets folder into a single file. But what does require_self tells?
kriysna
  • 6,118
  • 7
  • 30
  • 30
60
votes
6 answers

How to make Rails 3.1 use SASS (Over SCSS) as the default?

Having a hard time figuring out how to make SASS, not SCSS, as the default for stylesheets. I've tried making a sass_config.rb file with this: Sass::Plugin.options[:syntax] = :sass Sass::Plugin.options[:style] = :compressed I've also tried adding…
krainboltgreene
  • 1,841
  • 2
  • 17
  • 25
59
votes
2 answers

"Uninitialized constant" error when including a module

I am trying to reference an association extension but it errors with: NameError (uninitialized constant User::ListerExtension): app/models/user.rb:2:in `' Here is my implementation: app/models/user.rb class User < ActiveRecord::Base …
Coderama
  • 11,050
  • 12
  • 44
  • 58
58
votes
7 answers

Rails: Force empty string to NULL in the database

Is there an easy way (i.e. a configuration) to force ActiveRecord to save empty strings as NULL in the DB (if the column allows)? The reason for this is that if you have a NULLable string column in the DB without a default value, new records that…
Thilo
  • 17,565
  • 5
  • 68
  • 84
56
votes
18 answers

Ruby on Rails 3.1 and jQuery UI images

I'm using Ruby on Rails (Edge, the development version), and Ruby rvm 1.9.2. application.js is as follows. //= require jquery //= require jquery-ui //= require jquery_ujs //= require_tree Where is the right place in Ruby on Rails 3.1 to put the…
Henrik Ormåsen
  • 870
  • 1
  • 9
  • 18
56
votes
3 answers

How to get the total count after Kaminari pagination

I am using rails 3.2. I am paginating my results using .page(1).per_page(10) like @users = User.method().page(1).per_page(10) Now how to find the total count of the users from the pagination As because @users.count gives 10 from the first page…
useranon
  • 29,318
  • 31
  • 98
  • 146
55
votes
4 answers

How to avoid precompiled assets being served in development mode?

I prefer not to concatenate JavaScript files in development mode, but serve them as individual files. So I configured: development.rb: config.assets.compress = false config.assets.debug = true config.assets.compile = true In my…
Ortwin Gentz
  • 52,648
  • 24
  • 135
  • 213
53
votes
2 answers

Rails asset pipeline: Standard way for including all /vendor/assets/javascripts/?

I've been transitioning an app to Rails 3.1 (and now on to 3.2) and watched the Railscast on the asset pipeline. I moved all of my third-party jquery plugin files to the /vendor/assets/javascripts/ directory. In my…
robertwbradford
  • 6,181
  • 9
  • 36
  • 61
52
votes
8 answers

Rails 3.1 and jquery-ui assets

This was asked in another question, but none of the solutions appear to work for me in 3.1rc1. I'm trying to use the new assets stuff in rails 3.1 - I have the files:…
Roman Gaufman
  • 1,104
  • 1
  • 13
  • 17
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?…
50
votes
4 answers

Rails 3.1: Determine if asset exists

Is there a built-in way to determine if an asset exists without resorting to File.exists?(File.join(Rails.root, "foo", "bar", "baz")) and that looks through the asset paths. My app goes and fetches images from a remote server on a Resque queue;…
Jim Zajkowski
  • 987
  • 1
  • 7
  • 13
50
votes
4 answers

Rails 3.1 serving images from vendor/assets/images

I am trying to put some external images (used by a jQuery plugin) to vendor/assets/images in my Rails 3.1 app. Problem is that when I try something like: <%= image_tag "ui-bg_flat_75_ffffff_40x100.png" %> I get an error: No route matches [GET]…
Slobodan Kovacevic
  • 6,848
  • 3
  • 29
  • 33
49
votes
3 answers

Rails 3.1 asset precompilation - include all javascript files

I want Rails 3.1 to pick up more of my assets for precompilation. In particular, the default matcher for compiling files doesn't add .js files from vendor/assets/javascripts. I can just add the assets to the config.assets.precompile list, but this…
Peter
  • 127,331
  • 53
  • 180
  • 211
48
votes
8 answers

Best way to highlight current page in Rails 3? -- apply a css class to links conditionally

For the following code: <%= link_to "Some Page", some_path %> How do I apply a css class current using the current_page?‎ helper method? Or if some other better way is available?
Jacob
  • 6,317
  • 10
  • 40
  • 58