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

Authenticate user using omniauth and Facebook for a rails API?

I'm building a Rails API and have successfully built a way for a user to authenticate using Omniauth Identity. We simply post to auth/identity/callback from the client, passing in an auth_key and password. The server then returns a doorkeeper token…
idrysdale
  • 1,551
  • 2
  • 12
  • 23
56
votes
6 answers

Schema Migrations Table

In my Rails 4 app I would like to collapse my migration files into one large file (similar to schema.rb) as it's time to do some housekeeping but I'm not sure on how to access the table in the database that stores migration data so that when I run a…
tommyd456
  • 10,443
  • 26
  • 89
  • 163
56
votes
5 answers

rails validation: :allow_nil and :inclusion both needed at the same time

Usually the field 'kind' should be allowed blank. but if it is not blank, the value should included in ['a', 'b'] validates_inclusion_of :kind, :in => ['a', 'b'], :allow_nil => true The code does not work?
Daniel
  • 861
  • 1
  • 8
  • 12
56
votes
14 answers

What is the best way to convert all controller params from camelCase to snake_case in Rails?

As you already know, JSON naming convention advocates the use of camelCase and the Rails advocates the use of snake_case for parameter names. What is the best way to convert all request's params to snake_case in a rails controller? From this: { …
a.s.t.r.o
  • 3,261
  • 5
  • 34
  • 41
56
votes
2 answers

Github contributions graph

There is a wonderful contributions chart that github.com came with. Does anybody know if they use some kind of library or gem? If it is open source, I would like to use it my project as well. It looks great!
Alex Smolov
  • 1,831
  • 4
  • 24
  • 43
56
votes
2 answers

What does the j function in Rails do?

I just came across a blog that mentions a j function in Rails. They were using it to do ajax style page updates. $('#cart').html("<%=j render @cart %>"); I get they are using partials to render the cart partial, but whats the point of j? I've…
Tyler DeWitt
  • 23,366
  • 38
  • 119
  • 196
56
votes
3 answers

Rails: "BCrypt::Errors::InvalidHash" when trying to sign in

I am trying to finish a project. I am working with user models. When I signup everything seems ok . But when I try to signin the same member I get this error. We're sorry, but something went wrong. heroku logs file shows error…
ytsejam
  • 3,291
  • 7
  • 39
  • 69
55
votes
6 answers

Rails which files to ignore for GIT

I created a GIT repo, locally. I now see a bunch of files i rather ignore for GIT check-in. This brings me to the question: is there any default .gitignore for Rails? Any best practices? I think of tmp and log for sure. But are there any other…
Roger
  • 7,535
  • 5
  • 41
  • 63
55
votes
11 answers

Rails: Could not find railties

➜ ~ rvm -v rvm 1.10.2 by Wayne E. Seguin , Michal Papis [https://rvm.beginrescueend.com/] ➜ ~ ruby -v ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0] ➜ ~ rails…
pyronaur
  • 3,515
  • 6
  • 35
  • 52
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
55
votes
4 answers

How to set default Ruby version with RVM?

Ubuntu 11. I do the following: $ rvm --default use 1.9.2 and I get: Using /home/md/.rvm/gems/ruby-1.9.2-p180 so that is good. but when I now open a new terminal window I still get: $ ruby -v ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-linux]
Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
55
votes
1 answer

How to define action with simple form for?

I am trying to define the action "savenew" in admin/photographers controller. I have tried this: <%= simple_form_for(:photographer_savenew, :action => 'savenew', :id => params[:id], :multipart => true ) do |f| %> But the action in the form is…
Rails beginner
  • 14,321
  • 35
  • 137
  • 257
55
votes
5 answers

What is the proper "Rails Way" to consume a RESTful web service on another domain?

I would like to write a Ruby on Rails application that consumes a RESTful web service API performs some logic on the result and then displays that data on my view. For example, let's say I wanted to write a program that did a search on…
Mike Farmer
  • 2,992
  • 4
  • 28
  • 32
55
votes
3 answers

How to make carrierwave delete the file when destroying a record?

I'm using the carrierwave gem to upload files. I have built a system for users to flag images as inappropriate and for admins to remove the images. From what I can tell, calling destroy on the image will only remove the path name from the table. Is…
Oakland510
  • 1,073
  • 2
  • 12
  • 20
55
votes
7 answers

In Rails, how to get current URL (but no paths)

If I'm in a URL such as http://domain.example/mysite/bla How can I request just the URL with no paths? Such as http://domain.example
Martin
  • 11,216
  • 23
  • 83
  • 140