Hi there people!
I’m a newbie to both Rails & Ruby, I’ve just started reading the “Agile Development with Rails” book yesterday.
I’ve noticed that in most of the times, we 're calling functions without parentheses like validates :title, presence: true or assert product.invalid? Sometimes though (mostly in views as I’ve noticed) we’re using parentheses, like <%= number_to_currency(product.price, unit: “€”).
My question: is this generally the preferred way to code in Rails? If yes, why? Sorry if this sounds silly but I can’t clearly see why we prefer one way over the other.
Also, I think it’s kinda hard to get used to the parentheses-less style, cause everytime I see a line of code I must closely watch it’s syntax to determine if this is a function call or something else. Is it only me?
Generally, I’m following the rule that every piece of code that has a word and then a space and then something else, for example respond_to :blah, blu: ‘test’ is a function call, isn’t that right?
Thanks in advance.