为什么ActiveRecord :: StatementInvalid:SQLite3 :: SQLException:在“)”附近:语法错误:INSERT INTO“ user

编程入门 行业动态 更新时间:2024-10-28 09:20:30
本文介绍了为什么ActiveRecord :: StatementInvalid:SQLite3 :: SQLException:在“)”附近:语法错误:INSERT INTO“ user_friendships” ()个值()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

为什么要选择ActiveRecord :: StatementInvalid:SQLite3 :: SQLException:附近):语法错误:INSERT INTO user_friendships()VALUES()

Why Why ActiveRecord::StatementInvalid: SQLite3::SQLException: near ")": syntax error: INSERT INTO "user_friendships" () VALUES ()

尝试时测试:

$ ruby​​-我测试test / unit / user_friendships_test.rb

$ ruby -I test test/unit/user_friendships_test.rb

require 'test_helper' class UserFriendshipsTest < ActiveSupport::TestCase should belong_to (:user) should belong_to (:friend) test "that creating a frinedship works without raising an exception" do assert_nothing_raised do UserFriendship.create user: users(:a), friend: friends(:b) end end end

有什么想法吗?

更新:他的是Schema.rb

UPDATE: his is part of the Schema.rb

create_table "user_friendships", :force => true do |t| t.integer "user_id" t.integer "friend_id" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false end add_index "user_friendships", ["user_id", "friend_id"], :name => "index_user_friendships_on_user_id_and_friend_id" create_table "users", :force => true do |t| t.string "first_name" t.string "last_name" t.string "profile_name" t.string "email", :default => "", :null => false t.string "encrypted_password", :default => "", :null => false t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" t.integer "sign_in_count", :default => 0, :null => false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false end add_index "users", ["email"], :name => "index_users_on_email", :unique => true add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true end

推荐答案

I也碰到了这个它似乎与搞乱rails命名约定有关。就我而言,执行 rails g model activity_item而不是 rails g model activity_items即可解决此问题。

I ran into this as well. It seems to be related to screwing up the rails naming conventions. In my case, doing "rails g model activity_item" instead of "rails g model activity_items" solved the issue.

更多推荐

为什么ActiveRecord :: StatementInvalid:SQLite3 :: SQLException:在“)”附近:语法错误:INSERT I

本文发布于:2023-10-16 15:47:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1498019.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:语法错误   ActiveRecord   StatementInvalid   user   INSERT

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!