Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rolify tables are not getting created

Tags:

After bundle installing the gem(gem 'rolify'), I have generated the file using the following command,

rails g rolify Role User

Below files got created,

invoke  active_record
create    app/models/role.rb
invoke    rspec
create      spec/models/role_spec.rb
invoke      factory_girl
create        spec/factories/roles.rb
insert    app/models/role.rb
create    db/migrate/20140425070708_rolify_create_roles
insert  app/models/user.rb
create  config/initializers/rolify.rb

Then, i gave

rake db:migrate

Its giving me the warning,

[WARN] table 'Role' doesn't exist. Did you run the migration ? Ignoring rolify config.

Also tables are not getting created. What is the problem am i missing anything here.? This my migration file,

 class RolifyCreateRoles < ActiveRecord::Migration
    def change
     create_table(:roles) do |t|
      t.string :name
      t.references :resource, :polymorphic => true
      t.timestamps
     end

    create_table(:users_roles, :id => false) do |t|
      t.references :user
      t.references :role
    end

    add_index(:roles, :name)
    add_index(:roles, [ :name, :resource_type, :resource_id ])
    add_index(:users_roles, [ :user_id, :role_id ])
  end
 end

My versions,

Rails - 4.1.0 Ruby - 2.1.1

Please any one help me in this..

Thanks in advance.