Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 使用Rails 3.0 beta 3而不使用ActiveRecord ORM_Ruby On Rails_Ruby - Fatal编程技术网

Ruby on rails 使用Rails 3.0 beta 3而不使用ActiveRecord ORM

Ruby on rails 使用Rails 3.0 beta 3而不使用ActiveRecord ORM,ruby-on-rails,ruby,Ruby On Rails,Ruby,刚刚在Windows7中安装了Rails 3.0 beta 3。 开始玩一些简单的例子 class SignupController < ApplicationController def index @user = User.new(params[:user]) if method.post? and @user.save redirect_to :root end end end cl

刚刚在Windows7中安装了Rails 3.0 beta 3。 开始玩一些简单的例子

   class SignupController < ApplicationController
     def index
       @user = User.new(params[:user])
       if method.post? and @user.save
         redirect_to :root
       end
     end
   end

    class User
      def initialize(params = {})
        @email = params[:email]
        @passw = params[:password]
      end

      def save
      end
    end

<div align="center">
 <% form_for :user do |form| %>
  <%= form.label :email %>
  <%= form.text_field :email %><br />
  <%= form.label :password %>
  <%= form.text_field :password %><br />
  <%= form.submit :Register! %>
 <% end %>
</div>
类注册控制器

当我进入/注册时,我得到了这个错误

中的命名错误 注册控制器#索引

你有一个零对象,而你没有 期待吧!你可能会想到 数组的实例。发生了错误 在评估无时。[]

构造器有问题吗?有什么问题吗?请,需要您的帮助!
我只是不使用ActiveRecord或任何其他ORM。

您需要另一个操作来处理此帖子,它可能被称为
create
。以下是我将如何修改您的控制器:

def index
  @user = User.new
end

def create
  @user = User.new(params[:user])
  if method.post? and @user.save
    redirect_to :root
  end
end
该错误可能是因为当显示
索引时,
params
变量没有内容