Q:

Passing variable from Sinatra module to view?

I have function in a module in the lib dir of my Sinatra app, that I want to be able to pass
a variable back to a view.
Trying to pass it like :
@errorMessage = params["testing error"]
erb :error

Bring the error erb that's in ../views from the lib directory, but does not show the errorMessage var.
erb code :
<p> Error message : <% @errorMessage %></p>  

Anyone have any idea?

A:

You can try using :locals  
erb :error, :locals => {:errorMessage => "My message"}

And then use errorMessage as a variable inside your template.

A:

It should be <%= @errorMessage %> and not <% @errorMessage %>. 

