Questions tagged [ruby-on-rails]

Ruby on Rails is an open source full-stack web application framework written in Ruby. It follows the popular MVC framework model and is known for its "convention over configuration" approach to application development.

Ruby on Rails is an open-source full-stack web application framework created by David Heinemeier Hansson (DHH) in 2004 using the Ruby programming language. It is an optimized framework aimed at programmer's happiness and providing sustainable productivity by making use of CoC (Convention over Configuration), DRY (Don't Repeat Yourself), Active Record Pattern and REST (Representational State Transfer) philosophies.

It is based on the MVC Architectural Design Pattern, which separates web applications into three different modules:

  • Model
  • View
  • Controller

This helps to isolate business logic from presentation and makes code maintenance significantly easier as well as more flexible.

Ruby is the programming language used by Ruby on Rails

The tag is for questions related to the Ruby on Rails framework. This tag is particularly appropriate for questions about:

  • Rails MVC patterns
  • Rails objects
  • Rails methods
  • Rails gems
  • Rails views
  • Rails routes
  • Rails plugins
  • ActiveRecord object-relational mapping (ORM)

Questions about Ruby on Rails should not be tagged with [tag: ruby] unless the question is about the Ruby language in general, its syntax and libraries, or other questions not specific to the Ruby on Rails MVC framework.

Please see the Ruby tag wiki for more information about when it's appropriate to tag a question with instead of .

Specific Versions

Questions regarding specific versions of Ruby on Rails can also be asked on the appropriate tags:

Where to start

Interactive Ruby

  • Codecademy—Learn the fundamentals of Ruby and dynamic programming

Online Courses

  • Web Application Architectures—Learn how to build and deploy modern web application architectures—applications that run over the Internet, whereas in the "cloud" technology, deploy it using a browser as the user interface. We're going to learn about web apps through the Ruby on Rails framework. Rails is a framework for creating web applications that are built on top of the Ruby programming language.

Resources

Books

When asking Ruby on Rails questions, you should:

  1. Read the API documentation carefully and search Stack Overflow for duplicates.
  2. Mention the Ruby and the Ruby on Rails version related to the issue.
  3. Frame the question in a simple way, add code snippets if that could help the community to understand the problem better.
  4. Tag the question with appropriate tags so that there will be more visits to the page.
  5. Supply error information, if any—console log info is best.

Contributing to the community

  1. If you can solve the problem, spend some time answering the question.
  2. Upvote and downvote appropriately to rate and maintain the quality of questions and answers posted.

Contributing to Ruby on Rails

There are hundreds of people around the world who contribute to Ruby on Rails. You can start by following this guide.

Chat rooms

Related tags

337315 questions
55
votes
4 answers

For Rails, how to access or print out config variables (as experiment or test / debugging)

For example, in config/environments/production.rb in a Rails 3 app, there is config.serve_static_assets = false and many variables. How can they be all printed out as a whole (perhaps in an object, instead of specifying each one-by-one) (print out…
nonopolarity
  • 146,324
  • 131
  • 460
  • 740
55
votes
10 answers

Displaying a Carrierwave filename in the view

I am trying to display the filename of a Carrierwave attachment in a Rails erb template. The following does not work: <%= @page.form.filename %> This seems in line with the documentation. Is some additional step needed? My page model looks like…
Chris Alley
  • 3,015
  • 2
  • 21
  • 31
55
votes
5 answers

How to sign in a user using Devise from a Rails console?

After loading the Rails console, how should I sign in a user? Devise provides a test helper which can be used in tests and I've tried to use in console: >> include Devise::TestHelpers >> helper.sign_in(User.first) But I get: NoMethodError:…
Christian
  • 1,872
  • 1
  • 14
  • 14
55
votes
6 answers

How can I send mail with rails without a template?

In my Rails 3 project, I want to send some simple notification emails. I don't need to make a template for them or do any logic. I just want to fire them off from various places in the system. If I were doing this in an arbitrary ruby script I would…
John Bachir
  • 22,495
  • 29
  • 154
  • 227
55
votes
5 answers

In Ruby what does "=>" mean and how does it work?

While learning Ruby I've come across the "=>" operator on occasion. Usually I see it in the form of :symbol => value and it seems to be used frequently when passing values to functions. What exactly is that operator called? What does it do/mean?…
Dustin Martin
  • 1,297
  • 2
  • 12
  • 22
55
votes
4 answers

Rails 3: OpenSSL::SSL::SSLError: hostname was not match with the server certificate

When trying to deliver an email via console I receive this error: OpenSSL::SSL::SSLError: hostname was not match with the server certificate The thing is I really don't know much about certificates and such, or really how to get started…
JP Silvashy
  • 46,977
  • 48
  • 149
  • 227
55
votes
16 answers

link_to :confirm displays popup twice

This tag with rails 3 <%= link_to 'Destroy', item, :method => :delete,:confirm=>'Are you sure?' %> produces this html Destroy The entry is deleted, the problem…
user370731
  • 832
  • 1
  • 6
  • 10
55
votes
8 answers

How to change a Ruby on Rails application name?

I have a Ruby on Rails application that was created using: rails new old_name -d mysql Now I want to change the application name to be new_name. Just changing the application folder name will not be enough, because the database name, for example,…
Misha Moroshko
  • 166,356
  • 226
  • 505
  • 746
55
votes
4 answers

When I run the rake:db migrate command I get an error "Uninitialized constant CreateArticles"

I created a model ruby script/generate model Article (simple enuff) Here is the migration file create_articles.rb: def self.up create_table :articles do |t| t.column :user_id, :integer t.column :title, :string t.column :synopsis,…
featureBlend
  • 667
  • 1
  • 8
  • 10
55
votes
7 answers

How to set-up jquery-ui autocomplete in Rails

I need some help on how to implement a jquery-ui autocomplete in my Rails app. I want to add autocompletion to a text field where the user can enter in a customer name. As there can be hundreds of customers, I will need to pull the suggested…
Oscar
  • 3,218
  • 2
  • 26
  • 26
55
votes
2 answers

rails convert string to number

I am wondering what is a convenient function in Rails to convert a string with a negative sign into a number. e.g. -1005.32 When I use the .to_f method, the number becomes 1005 with the negative sign and decimal part being ignored.
Yang
  • 9,794
  • 15
  • 44
  • 52
55
votes
4 answers

Get specific attributes from an ActiveRecord model

Let's say that I have a User model with attributes :id, :first_name, :last_name, and :email. In my application, guest users shouldn't see User's email and last_name. I know how to select specific values if I want a list of users but I don't know how…
vasilakisfil
  • 2,279
  • 4
  • 24
  • 31
55
votes
4 answers

Irregular bootstrap column wrapping

Running Rails 4.1.4 with the latest releases of haml, haml-rails, sass, and bootstrap-sass. For a user display, my HAML is as such: .tutors-listing .row - @users.each do |tutor| .col-xs-12.col-md-3 .row.tutor …
Benoît
  • 601
  • 1
  • 5
  • 10
55
votes
8 answers

PG::ConnectionBad: fe_sendauth: no password supplied

When I attempt to run "rake test" on a local postgres database, it throws the above exception. Here is my pg_hba.conf file: # Database administrative login by Unix domain socket local all postgres …
Lawrence I. Siden
  • 9,191
  • 10
  • 43
  • 56
55
votes
3 answers

Rails: respond_to JSON and HTML

I have a controller "UserController" that should respond to normal and ajax requests to http://localhost:3000/user/3. When it is a normal request, I want to render my view. When it is an AJAX request, I want to return JSON. The correct approach…
Don P
  • 60,113
  • 114
  • 300
  • 432
1 2 3
99
100