0

我做了一个项目并通过以下命令将其推送到 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并输入 to 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
4

1 回答 1

2

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

rake db:migrate

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

rake db:seed

“重定向太多”错误可能是由于重定向时CanCan::AccessDenied抛出的。我怀疑您的root_urlis 也需要身份验证,这会导致另一个CanCan::AccessDenied,它重定向到root_urland on 和 on 。

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

于 2013-01-03T16:25:14.123 回答