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

How to make a Ruby string safe for a filesystem?

I have user entries as filenames. Of course this is not a good idea, so I want to drop everything except [a-z], [A-Z], [0-9], _ and -. For instance: my§document$is°° very&interesting___thisIs%nice445.doc.pdf should…
marcgg
  • 65,020
  • 52
  • 178
  • 231
55
votes
13 answers

How to get the selected date value while using Bootstrap Datepicker?

Using jquery and the Bootstrap Datepicker, how do I get the new date value I selected using the Bootstrap Datepicker? FYI, I'm using Rails 3 and Coffescript. I set up the datapicker using:
Ryan
  • 10,798
  • 11
  • 46
  • 60
55
votes
3 answers

after_create :foo vs after_commit :bar, :on => :create

Is there any difference between: after_create :after_create and after_commit :after_commit_on_create, :on => :create Can these be used interchangeably?
Bill
  • 3,059
  • 3
  • 31
  • 47
55
votes
13 answers

cannot load such file -- openssl (LoadError)

In OS X in rvm how do I check if openssl is configured properly? I get the cannot load such file -- openssl (LoadError) And I have tried everything in Rails 3 - no such file to load -- openssl with no success.
Bruno
  • 6,211
  • 16
  • 69
  • 104
55
votes
4 answers

Rails: named_scope, lambda and blocks

I thought the following two were equivalent: named_scope :admin, lambda { |company_id| {:conditions => ['company_id = ?', company_id]} } named_scope :admin, lambda do |company_id| {:conditions => ['company_id = ?', company_id]} end but Ruby is…
Gav
  • 11,062
  • 7
  • 33
  • 35
55
votes
3 answers

How to disable Rack-Mini-Profiler temporarily?

I'm using rack mini profiler in rails just fine, but during some coding sessions especially where I'm working on a lot of different client side code, it gets in the way. (mainly in my client side debugging tools network graphs, etc.) I'm trying to…
Dave Sanders
  • 3,135
  • 4
  • 33
  • 43
55
votes
2 answers

Gem file with git remote failing on heroku push

I have the following line in my gemfile: gem 'client_side_validations', :git => "git@github.com:Dakuan/client_side_validations.git", :branch => "master", ref: '2245b4174ffd4b400d999cb5a2b6dccc0289eb67' The repo it's pointing at is public and I can…
Dom Barker
  • 1,889
  • 1
  • 16
  • 29
55
votes
4 answers

Difference between resource and resources in rails routing?

what is the difference between resource and resources in rails routing resource :geocoder and resources :posts What is real difference between them ?
Manish Shrivastava
  • 30,617
  • 13
  • 97
  • 101
55
votes
2 answers

How to tell which format a controller has resolved to render

In a rails controller action with the following code: respond_to do |format| format.json{ render :json=> {:status => 200, :response=>@some_resource} } format.html { redirect_to(some_resource_path)} end How can I log the format the controller…
Undistraction
  • 42,754
  • 56
  • 195
  • 331
55
votes
2 answers

Rails - Validate on Create Only

I'm trying to get my custom validation to work on create. But when I do a find then save, rails treats it as create and runs the custom validation. How do I get the validations to only work when creating a new record on not on the update of a found…
oprogfrogo
  • 2,005
  • 5
  • 31
  • 42
54
votes
5 answers

Multiple objects in a Rails form

I want to edit multiple items of my model photo in one form. I am unsure of how to correctly present and POST this with a form, as well as how to gather the items in the update action in the controller. This is what I want:
Espen
  • 2,133
  • 4
  • 19
  • 19
54
votes
6 answers

Visit method not found in my rspec

My java web application is running on tomcat at http://localhost:8080/ Writing my first spec, home_spec: require 'spec_helper' describe "home" do it "should render the home page" do visit "/" page.should have_content("hello…
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
54
votes
6 answers

foreman only shows line with “started with pid #” and nothing else

When I run foreman I get the following: > foreman start 16:47:56 web.1 | started with pid 27122 Only if I stop it (via ctrl-c) it shows me what is missing: ^CSIGINT received 16:49:26 system | sending SIGTERM to all processes 16:49:26 web.1…
ijverig
  • 2,795
  • 3
  • 18
  • 26
54
votes
3 answers

Rails ActiveRecord: How do I know if find_or_create_by found or created?

If I do widget = Widget.find_or_create_by_widgetid(:widgetid => "12345", :param2 => "folk") etc. then how do I tell if newobj is a found or newly created Widget? Is there something I can test conditionally on widget that will tell me?
Dave
  • 11,392
  • 5
  • 31
  • 42
54
votes
7 answers

Rails: How to test code in the lib/ directory?

I have a model which gets its data from a parser object. I'm thinking that the parser class should live in the lib/ directory (although I could be persuaded that it should live soewhere else). The question is: Where should my unit tests for the…
KaptajnKold
  • 10,638
  • 10
  • 41
  • 56
1 2 3
99
100