I’m going through the railstutorial.org book and getting a compile time error in code
<div class="center hero-unit">
<h1>Welcome to the Sample App</h1>
<h2>
This is the home page for the
<a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
sample application.
</h2>
<%= link_to "Sign up now!", '#', class: "btn btn-large btn-primary" %>
</div>
<%= link_to image_tag("rails.png", alt: "Rails"), 'http://rubyonrails.org/' %>
my error is
compile error
/home/ritesh/projects/sample/app/views/static_pages/home.html.erb:8: syntax error, unexpected ':'
...to "Sign up now!", '#', class: "btn btn-large btn-primary" )...
^
/home/ritesh/projects/sample/app/views/static_pages/home.html.erb:10: syntax error, unexpected ':', expecting ')'
...to image_tag("rails.png", alt: "Rails"), 'http://rubyonrails...
^
/home/ritesh/projects/sample/app/views/static_pages/home.html.erb:10: syntax error, unexpected ')', expecting kEND
...), 'http://rubyonrails.org/' );@output_buffer.safe_concat('
^
i think : should be there after class.can any one please suggest how to rectify this error
Try using
:class =>syntax instead ofclass:.For example, instead of:
write
I highly suspect you’re using a Ruby version not supporting `s syntax. In that case, try updating Ruby to 1.9.x.
EDIT:
As your Ruby version is 1.8.7 this will give you compile errors as the syntax is first introduced in Ruby 1.9 . When you install Ruby 1.9, writing either way is correct.