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! While you're at it, check out some resources Treehouse students have shared here.

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

Ruby Practice Sinatra Basics HTML Forms HTML Forms

MaryAnn Eleanya
MaryAnn Eleanya
8,626 Points

I don't know what is wrong?


require "sinatra"

get "/input" do
  erb :input

post "/reverse" do
  @string= String.reverse(params[:string]) 
<form method = "post" action = "/reverse">
  <input type= "text" name ="string">
  <input type = "submit">


1 Answer

Instead of String.reverse(params[:string]), try...


.reverse isn't a method directly on the String class, it is a method on its instances.

my_string = 'hello world'
String.reverse(my_string)  # invalid
my_string.reverse          # valid