当我使用git clone时找不到表'users'

时间:2013-01-03 15:44:44

标签: ruby-on-rails clone

我创建了一个项目并通过下一个命令将其推送到github:

step 1) create a new repository, is called: todolist

然后:

$ git init
$ git add .
$ git commit -m "My first application"
$ git remote add origin https://github.com/alonshmiel/todolist.git
$ git pull origin master
$ git push origin master

我跑:git pull origin master,因为我在push之前阅读了一个主题,我们需要pull

这是我的存储库的网址:

https://github.com/alonshmiel/todolist.git

在我的项目中,我定义了db/seeds.rb

Role.create({name: "Admin"})
Role.create({name: "Worker"})

user1 = User.create!(
    email: "admin216@gmail.com",
    password: "12345678",
    password_confirmation: "12345678"
)
user1.role_ids = [1]

user2 = User.create!(
    email: "worker216@gmail.com",
    password: "12345678",
    password_confirmation: "12345678"
)

当我运行下一个命令时:

git clone https://github.com/alonshmiel/todolist.git

我的项目已加载到我的电脑上。

所以我跑:

rails s并输入localhost:3000,但我收到了错误消息:

Could not find table 'users'

有人能告诉我问题是什么吗?任何帮助表示赞赏!

更新

我跑:

$ bundle exec rake db:migrate
$ bundle exec rake db:seed

但现在,我收到了一个错误:

  

http://localhost:3000/的网站似乎无法使用。确切的错误是:
      重定向太多

在我将它上传到github之前,这个错误没有出现在我的真实项目中。

这是我的application_controller

class ApplicationController < ActionController::Base
  protect_from_forgery
  before_filter :authenticate_user!

  rescue_from CanCan::AccessDenied do |exception|
    redirect_to root_url, :alert => exception.message
  end

  def after_sign_out_path_for(user)
    new_user_session_path
  end

end

这些是我的其他控制者:

class TasksadminsController < ApplicationController

  load_and_authorize_resource :except => [:update, :show]

  def index
  ....
end

class WorkersController < ApplicationController

  load_and_authorize_resource :except => [:edit, :update]

  def index
  ....
end

1 个答案:

答案 0 :(得分:2)

克隆应用程序后,需要将数据库升级到最新版本。您可以通过运行:

来完成此操作
rake db:migrate

要将db/seeds.rb中的数据放入您需要运行的数据库中:

rake db:seed

“Too many redirects”错误可能是因为抛出CanCan::AccessDenied时的重定向。我怀疑您的root_url还需要身份验证,这会产生另一个CanCan::AccessDenied,会重定向到root_url并依次开启。

您应该重定向到没有身份验证的页面,例如注册页面。