0
当我访问本地主机:3000, 我的浏览器在ConnectionController#index中告诉错误NoMethodError。 此外,我被告知ConnectionController(表不存在)的未定义方法`行动':类。ConnectionController中的NoMethodError#index
错误浏览器告诉26行的connection_controller.rb是错误的,但我没有像26行一样编写代码。
send(name, *arguments, &block)
else
super
end
end
我写的,在connection_controller.rb
class ConnectionController < ActiveRecord::Base
def index
personal = {'name'=>'Yamada','old'=>28}
render :json => personal
end
end
,
Rails.application.routes.draw do
namespace :connection do
get '/',action:'index'
end
end
在schema.rb
ActiveRecord::Schema.define(version: 20170101073143) do
create_table "userdata", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
end
,
class CreateUserdata < ActiveRecord::Migration
def change
create_table :userdata do |t|
t.string :name
t.text :image
t.timestamps null: false
end
end
end
模型,
class Userdatum < ActiveRecord::Base
\t user = User.new
\t user.name = "XXX"
\t user.email = "mail"
\t user.save
end