Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8732751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:29:42+00:00 2026-06-13T09:29:42+00:00

Inconsistent naming conventions in Rails are confusing me. It seems like the syntax is

  • 0

Inconsistent naming conventions in Rails are confusing me. It seems like the syntax is all over the place. Here are some examples:

Why are there commas in the migration below? And, why doesn’t the keyword default have a colon before it? What is this default keyword, a method, or a variable, a symbol? What is that thing?:

add_column :zombies, :rotting, :boolean, default: false

Here is another example:

Why is age not :age (with a colon)? Why is make_rotting called with a “:” before it?

 class Zombie < ActiveRecord::Base
       before_save :make_rotting

   def make_rotting
      if age > 20
         self.rotting = true
      end
    end
 end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:29:44+00:00Added an answer on June 13, 2026 at 9:29 am

    Ruby can be hard for Java and PHP people. 🙂

    In Ruby, not everything is what it appears to be. Take this, for example:

    before_save :make_rotting
    

    This is a method call, sure. But it’s not the make_rotting method that is called. It’s the before_save (:make_rotting is its parameter). This is a so-called hook in ActiveRecord. before_save will take a method name as a parameter and will dynamically call it when the moment comes.

    if age > 20
    

    Here age is a method call, not a symbol. It could be written as:

    if age() > 20
    

    but the parentheses are optional. And lastly:

    add_column :zombies, :rotting, :boolean, default: false
    

    This method takes four parameters, the last of which is a hash. The hash uses the new Ruby 1.9 syntax. Previously it would be written like this (with the colon in the right place, and all):

    add_column :zombies, :rotting, :boolean, :default => false
    

    You should read a good book on Ruby programming, instead of scraping pieces of knowledge from Stack Overflow posts. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Updated this post as per post recommendations: Inconsistent naming conventions in rails is confusing
Seems like it's inconsistent in the lists module. For example, split has the number
I am in the process of unifying these inconsistent naming conventions and this one
I am tidying up my ancient Cocoa code to use modern naming conventions. There
PHP has some pretty inconsistent parameters for functions (e.g. sometimes first haystack , then
I've noticed some inconsistent (inconsistent to me) behaviour in data.table when using different assignment
I'm seeing inconsistent behaviour when calling setResult() and finish() on some activities that were
I just read two articles over this topic which provide infomration inconsistent, so I
I've noticed that the word monad seems to be used in a somewhat inconsistent
I am bitten by this little inconsistent debugger behavior. The quotemeta() function seems to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.