I am trying to create this rails migration
class CreateFormats < ActiveRecord::Migration
def self.up
create_table (:formats , :options => 'ENGINE=InnoDB DEFAULT CHARSET=utf8' ) do |t|
t.name
t.description
t.company
t.timestamps
end
end
def self.down
drop_table :formats
end
end
And I get errors during execution that look like this:
syntax error, unexpected ‘,’, expecting ‘)’
create_table (:formats , :options => ‘ENGINE=InnoDB D…
^
syntax error, unexpected ‘)’, expecting keyword_end
…=InnoDB DEFAULT CHARSET=utf8′ ) do |t|
… ^
syntax error, unexpected keyword_end, expecting $end
Any idea why this happened? I can’t find any problems with my syntax..most likely because I am new to Rails 🙂
Your syntax is incorrect:
should be
i.e: without the space. Otherwise you are simply grouping
:formatswith:options => ...as the first argument to the function.You probably also need to change
to something like