Skip to content

Instantly share code, notes, and snippets.

@jasonleonhard
Created May 20, 2015 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonleonhard/f4c05ab712388c878bc0 to your computer and use it in GitHub Desktop.
Save jasonleonhard/f4c05ab712388c878bc0 to your computer and use it in GitHub Desktop.
rails whitespace syntax error
# this one will not work, it creates a syntax error
class ArticlesController < ApplicationController
def new
end
  
def create
render plain: params[:article].inspect
  end
end
but this does work...
class ArticlesController < ApplicationController
def new
end
def create
render plain: params[:article].inspect
end
end
@jasonleonhard
Copy link
Author

looking at the raw I see some characters

this one will not work, it creates a syntax error

class ArticlesController < ApplicationController
def new
end
 Â
def create
render plain: params[:article].inspect
  end
end

but this does work...

class ArticlesController < ApplicationController
def new
end

def create
render plain: params[:article].inspect
end
end

@jasonleonhard
Copy link
Author

A unicode character is generated for white spaces that throws a syntax error.... perhaps sublime text editor did this?

@jasonleonhard
Copy link
Author

articles_controller.rb:8: syntax error, unexpected end-of-input, expecting keyword_end

@jasonleonhard
Copy link
Author

<%- and -%> suppress leading and trailing whitespace
Is this required to not receive the unicode characters?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment