0

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

6
  • I think you're misusing the provide method. What do you want to achieve here? Commented Mar 3, 2016 at 14:07
  • Get rid of the brackets or get rid of the space between provide and first bracket. Commented Mar 3, 2016 at 14:09
  • I've seen the use of the provide method in the Michael Hartl tutorial to attain a uniform title Commented Mar 3, 2016 at 14:10
  • And what's the syntax error returned? Commented Mar 3, 2016 at 14:11
  • @lcguida - It is common to use provide for page title like this. Commented Mar 3, 2016 at 14:11

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.