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
19
votes
3 answers

Rails select tag selected value

My tag: <%= select_tag(:option, options_for_select([['All', 1], ['Co', 2], ['Bought', 3], ['View', 4], ['Top API', 5], :selected => :option ])) %> How do I set the selected value to which option is selected. For example, if I select ['Bought', 3],…
Yogzzz
  • 2,735
  • 5
  • 36
  • 56
19
votes
3 answers

"Command failed with status ()" when precompiling assets

I am having similiar problems like a lot of users when compiling assets on their productive box. The only difference is that I can't get any hint out of the trace to solve the problem. rake assets:precompile RAILS_ENV=production --trace ** Invoke…
pdu
  • 10,295
  • 4
  • 58
  • 95
19
votes
3 answers

query where date = Date.today with Rails, MySQL, and Active Record

I see in the Active Record docs, you can query for a date using a greater than / less than comparison. However, what if you want to select where date = Date.today or must I query where date is greater than yesterday and less than tomorrow? As you…
jdkealy
  • 4,807
  • 6
  • 34
  • 56
19
votes
7 answers

How do you create javascript functions that are available project-wide in Ruby on Rails?

I put the following function in my application.js: function test() { alert("See Me") } classrooms/_new_small.html.haml: :javascript alert('test'); test(); In my application.html.haml I'm using the following: = javascript_include_tag…
perseverance
  • 6,372
  • 12
  • 49
  • 68
19
votes
1 answer

Define the length of varchar for MySQL in rails

I want to define the size of the varchar in rails for example name varchar(20), age varchar(6),through git-bash in process of generating the model. I searched on the stack but couldn't find any answer.
Sachin Prasad
  • 5,365
  • 12
  • 54
  • 101
19
votes
3 answers

custom rails has_many association ( through pg array )

So basically I'd like to know if there's some common approach to define own association types. Some details: I have a model conversations that has a PG array column user_ids. So, to retrieve user conversations I need to run: select conversations.*…
Vlad Khomich
  • 5,820
  • 1
  • 27
  • 39
19
votes
2 answers

save_and_open_page not working with capybara 2.0?

I just had my capybara updated to 2.0, and all of my save_and_open_page calls return an html page without styling. It has the style sheets links properly at the top of the page. When I revert back to capybara 1.3, the styles work again. Anyone…
Taylored Web Sites
  • 1,017
  • 1
  • 9
  • 15
19
votes
3 answers

Applying a different order to postgres "DISTINCT ON" using rails

I have a rails app: user has_many :projects user has_many :tasks, :through => :projects project has_many :tasks Each task has a milestone date. To show a table of project details with next milestone date I am using: @projects =…
user1116573
  • 2,817
  • 4
  • 17
  • 27
19
votes
4 answers

ERROR bad Request-Line - Force ssl - rails

I set force_ssl to true by accident and then when reverting to false and running server I get the following error: ERROR bad Request-Line WEBrick 1.3.1 INFO ruby 1.9.3 (2012-02-16) [x86_64-darwin11.4.0] WEBrick::HTTPServer#start: pid=472…
Benamir
  • 1,107
  • 2
  • 11
  • 24
19
votes
1 answer

Rails invalid datetime on model results in nil

I have a model with a datetime attribute. I am trying to validate incoming JSON which would update the model. But ActiveRecord seems to be setting the value of the attribute to nil if it is an invalid datetime. I can't respond with the appropriate…
19
votes
3 answers

With Rails UJS, how to submit a remote form from a function

I'm using Rails UJS. I have a form setup to do a remote submit like so:
I'm…
AnApprentice
  • 108,152
  • 195
  • 629
  • 1,012
19
votes
3 answers

How to check in development or production in ERB file in Rails?

I want to load jQuery UI via Google CDN if in production and locally if in development. So in my application.html.erb layout, I've got to know whether I'm in production or dev. Is there a variable I can check?
19
votes
2 answers

How to eager load association for an array of model records

I have an array of Rails model records. Is it possible to eager load an association for all these records in one go (query)? Sometimes I only have an array instead of an AR::Scope. And sometimes I want to dynamically choose what to eager load later.
lulalala
  • 17,572
  • 15
  • 110
  • 169
19
votes
2 answers

Memory grows indefinitely in an empty Rails app

I can't figure out why my Rails app (hosted on Heroku (cedar)) keeps allocating more and more memory. If I didn't know any better I'd say that this a memory leak in Ruby/Rails, but since I'm completely new to Ruby/Rails, I feel like I'm missing…
user1650177
  • 445
  • 3
  • 10
19
votes
7 answers

rake assets:precompile undefined method `[]' for nil:NilClass

I'm trying to get a new production server up and running and it is so close. When I execute RAILS_ENV=production rake assets:precompile This error is returned undefined method `[]' for nil:NilClass When I run it with a --trace, this is…
Russ Petersen
  • 765
  • 1
  • 9
  • 29