# Rake aborted - syntax error, unexpected $end, expecting kEND

**URL:** <https://www.ruby-forum.com/t/rake-aborted-syntax-error-unexpected-end-expecting-kend/92213>\
**Category:** Rails\
**Created:** [April 17, 2007, 5:14am UTC](https://www.ruby-forum.com/t/rake-aborted-syntax-error-unexpected-end-expecting-kend/92213 "2007-04-17T05:14:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dacbo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b9e5f3/32.png) [@dacbo](https://www.ruby-forum.com/u/dacbo)\
**Post date:** [April 17, 2007, 5:14am UTC](https://www.ruby-forum.com/t/rake-aborted-syntax-error-unexpected-end-expecting-kend/92213/1 "2007-04-17T05:14:56Z")

</div>

I can’t create tables via rake db:migrate without encountering this  
error:

rake aborted!  
./db/migrate//001\_create\_users\_table.rb:11: syntax error, unexpected  
$end, expecting kEND

The 001\_create\_users\_table.rb file contains:

class CreateUsersTable \< ActiveRecord::Migration  
def self.up  
create\_table “users” do |table|  
end

def self.down  
end  
end

I’ve recently installed RoR (as per  
[Dan Benjamin](http://hivelogic.com/narrative/articles/ruby-rails-mongrel-mysql-osx))  
and have been able to verify that everything is installed. I can create  
tables ‘manually’ in MySQL databases, but rake is failing every time  
with the same error as above.

Any help would be greatly appreciated. I’m investigating RoR with a view  
to building some web apps with it, but this is hardly an auspicious  
beginning.

---

<div class="post-metadata">

**Author:** ![dacbo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b9e5f3/32.png) [@dacbo](https://www.ruby-forum.com/u/dacbo)\
**Post date:** [April 17, 2007, 5:20am UTC](https://www.ruby-forum.com/t/rake-aborted-syntax-error-unexpected-end-expecting-kend/92213/2 "2007-04-17T05:20:11Z")

</div>

Chris B. wrote:

> class CreateUsersTable \< ActiveRecord::Migration  
> def self.up  
> create\_table “users” do |table|
> 
> end

You have a do in the line above which should be terminated with an end.  
This “end” closes the “do” above, but nothing closes the “def” for the  
self.up method.

> def self.down  
> end  
> end

Try something like:

class CreateUsersTable \< ActiveRecord::Migration  
def self.up  
create\_table “users” do |table|  
#do something here like creating fields inside the table  
end  
end

def self.down  
end  
end

Cheers  
Mohit.

---

<div class="post-metadata">

**Author:** ![dacbo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b9e5f3/32.png) [@dacbo](https://www.ruby-forum.com/u/dacbo)\
**Post date:** [April 17, 2007, 10:11pm UTC](https://www.ruby-forum.com/t/rake-aborted-syntax-error-unexpected-end-expecting-kend/92213/3 "2007-04-17T22:11:37Z")

</div>

Thanks for your reply - you’re quite right, of course. I’ll pay more  
attention when copying and pasting sample code next time!

Mohit S. wrote:

> Chris B. wrote:
> 
> > class CreateUsersTable \< ActiveRecord::Migration  
> > def self.up  
> > create\_table “users” do |table|
> > 
> > end
> 
> You have a do in the line above which should be terminated with an end.  
> This “end” closes the “do” above, but nothing closes the “def” for the  
> self.up method.
