I'm trying to use the <% provide (:title, 'home') %>
but a syntax error is returned. should I install a gem for it to work. Thanks in advance
Asked
Active
Viewed 121 times
0

Maxime Rouiller
- 13,614
- 9
- 57
- 107

Vic Turuthi
- 5
- 1
- 4
-
I think you're misusing the `provide` method. What do you want to achieve here? – lcguida Mar 03 '16 at 14:07
-
Get rid of the brackets or get rid of the space between provide and first bracket. – BroiSatse Mar 03 '16 at 14:09
-
I've seen the use of the provide method in the Michael Hartl tutorial to attain a uniform title – Vic Turuthi Mar 03 '16 at 14:10
-
And what's the syntax error returned? – lcguida Mar 03 '16 at 14:11
-
@lcguida - It is common to use provide for page title like this. – BroiSatse Mar 03 '16 at 14:11
-
@BroiSatse thanks man, that worked. appreciate it – Vic Turuthi Mar 03 '16 at 14:11
1 Answers
2
In Ruby the parens around a method call are optional:
provide :title, 'home'
But when using parens there should not be space between the method name and the parens:
def add(args*)
args.sum
end
add 1, 2 # => 3
add(1,2) # => 3
add (1,2) # syntax error, unexpected ',', expecting ')'
add (1+2), (1+2) # => 6
In the last examples you can see that Ruby treats the parens as a single argument when there is a space - which is why it gives a syntax error.

max
- 96,212
- 14
- 104
- 165