Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Kyle Shamblin9,945 Points
What am I doing wrong? Bug?
Am I making a syntax error or is this a bug? Thanks in advance.
require "sinatra" get "/hello" do erb: welcome.erb end
<h1>Welcome to our app!</h1>
Kevin Korte28,148 Points
I'm not really familiar with sinatra, but your code looks like it doesn't match the example code in the docs. They have
get '/' do erb :index end
Which, you have your colon in the wrong spot. Try fixing that and let us know how it works
Jacob Herrington15,835 Points
Hey Kyle Shamblin,
Just for future reference, in Ruby the colon sigil denotes a symbol. You can read more about symbols in this blog post from 2005.
For a easy to swallow example:
# strings "foo" & "foo" are not the same object "foo".equal? "foo" # false # symbols :foo & :foo are the same object :foo.equal? :foo # true
If you understand the symbol you will understand that
erb :welcome is just a symbol (:welcome) being passed to a method (erb).
Also, note that Ruby doesn't require parentheses when passing a single argument to a method. Jay McGavren has decided to write the code without the parentheses. If it helps you remember the syntax, you can also write it like this:
# get and erb are methods, you can pass a single argument with or without parentheses get("/hello") do erb(:welcome) end