JGallardo JGallardo - 1 year ago 73
Ruby Question

What is the proper way of naming slim files using numbers for a Sinatra project?

In my Sinatra app, I am getting an error

syntax error, unexpected tINTEGER, expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END

when I try to name my files something like 1.slim but not getting the error when I do something like this like calling it page1.slim

This is how I had my route that gave me an error


get '/1' do
slim :1

but it works fine when I do something like

get '/1' do
slim :page1

What's the problem? in Ruby apps can I not name a view starting with a number?

Answer Source

It's not about view, slim or something else. it's a symbol thing.

:1 #syntax error

You can do that like


In your case, the route would look like

get '/1' do
  slim :"1"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download