Rails 4 - syntax error, unexpected tIDENTIFIER, expecting end-of-input
You seem to indeed have been bitten by the "zero-width space problem". This is extremely frustrating, I know. You'd think that "show white space" should take care of the problem, particularly in an editor as advanced as Sublime.
In any event, to detect the existence of these characters in Sublime 2, you can use this plugin. to display them.
As an aside, I wasted hours if not days on this problem a few months ago when I copy/pasted some code from a website that had one of the little nasties in it.
I searched the Sublime 2 site for any postings related to this (e.g. feature requests, etc.), but didn't find anything, so I don't know if this is on their radar.
Note: The original version of this answer assumed that the zero-width space character was the same as the non-breaking space, which it is not. Non-breaking spaces, while they will still generate syntax errors, are much easier to detect since they "take up space" in your display (i.e. "look like" a space). There's also the "zero-width non-breaking space", which is different still. While it's easy to enter the non-breaking space on a Mac (i.e. Option-Space), I know of no way to enter any of the zero-width spaces.
syntax error, unexpected tIDENTIFIER, expecting end-of-input
Because in line:
cert = OpenSSL::X509::Certificate.new File.read 'cert.crt’
you have an opening single quote and then a different kind of quote-like character around cert.crt
.
By the way, you also have the same error in line:
pkey = OpenSSL::PKey::RSA.new File.read 'pkey.pem’
around pkey.pem
, which is not detected, but will be when you correct the first error.
Rails: syntax error, unexpected tIDENTIFIER, expecting keyword_end
The error tells you exactly where the problem is.
add has_many :bookmarks to app/models/user.rb
add belongs_to :user to app/model/user.rb
this should not be in a migration since they do not change the schema. You need to add these to the bookmark and user model, so
class Bookmark < ActiveRecord::Base
belongs_to :user
end
class User < ActiveRecord::Base
has_many :bookmarks
end
Syntax Error syntax error, unexpected tIDENTIFIER, expecting =
I don't know Hydra, but if this example is valid syntax:
attribute :title,
datastream: :descMetadata, multiple: false,
validates: { presence: { message: 'Your article must have a title.' } }
Then this example has an invalid hash in the third line and an invalid regexp (as Vasfed already pointed out):
attribute :title,
datastream: :descMetadata, multiple: false,
validates: { :title, format: { without: ^\s+$, message: "no spaces" } }
I would try to fix that by removing the duplicate :title
:
attribute :title,
datastream: :descMetadata, multiple: false,
validates: { format: { without: /^\s+$/, message: "no spaces" } }
Ruby: syntax error, unexpected tIDENTIFIER, expecting ')'
Not always errors are on the same lines as interpreter says ;) So it would be better if you include some adjacent lines next time. But as I found these lines are:
puts "We can also do that this way:"
puts "We'd have %d beans, %d jars, and %d crabapples." % secret_formula(start_pont
sentence = "All god\tthings come to those who weight."
words = ex25.break_words(sentence)
sorted_words = ex25.sort_words(words)
From here we see that the line before your specified line doesn't have closing parenthesis ')'.
syntax error, unexpected tIDENTIFIER, expecting ')'
There is no AND
operator in ruby.
To use AND
in a where statement you could either specify both the arguments.
@men_active_leagues = League.where(active: true, kind: 'men').order('id ASC').find_all
or you could specify it as a string
@men_active_leagues = League.where("active = TRUE AND kind = 'men'").order('id ASC').find_all
Unexpected tIDENTIFIER, expecting keyword_do or '{' or '('
There is a problem with your quotes. Change you code with:
def update
if @post.update(post_params)
redirect_to @post, notice: "Update successful" # changed here
else
render 'edit' # changed here
end
end
Related Topics
Call Task More Than Once in Rails 3 Generator
Url_For of a Custom Restful Resource (Composite Key; Not Just Id)
Ruby Model Output Id as Object Oid
Does C1 Code Coverage Analysis Exist for Ruby
Rspec and Shoulda - Complementary or Alternatives
Watir. Scroll to a Certain Point of the Page
How to Save Dates in Local Timezone to Db with Rails3
Rails 4 - Syntax Error, Unexpected Tidentifier, Expecting End-Of-Input
Restful File Uploads with Carrierwave
Gem Not Found in Ruby Cron Job in Rvm Env
Setting Up Facets in Elasticsearch with Searchkick Gem in Rails 4.1
Why Can't I Install SASS on MAC Os Sierra
Pry Not Stopping When Called from a Ruby Script That Reads from Stdin
Why Is This Permissions Error Occurring with Mod_Passenger.So
Open and Save Base64 Encoded Image Data Uri in Ruby