-1
NOTEを使用してデータベースのレコードを挿入する方法:私はRailsの5を使用していますRails 3 : How to insert Record in Database using Railsレール5:私はすでにこれを読んできたレール(HTML5)
。
私はデータベースにレコードを挿入する方法を教えてください。
私はMYSQLをuisng、および以下の私のテーブルの構造は、dbフォルダに正しいschema.rbになることです
ActiveRecord::Schema.define(version: 20161107113839) do
`create_table "allusers", force: :cascade, options: "ENGINE=InnoDB `DEFAULT CHARSET=latin1" do |t|`
t.string "username", limit: 50, null: false
t.string "email", limit: 50
t.string "password", limit: 50
t.string "likedvideos", limit: 50
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
end
ていますこれは私のコントローラファイルのuser1_controller.rbある
class User1Controller < ApplicationController
def user1index
end
これは私のモデルでありますファイルalluser.rb
class Alluser < ApplicationRecord
end
これは\ app \ views \ user1 \ user1index.htmlのビューファイルです.erb
<form <% @user1,:action => :new, :method => :post %> >
username: <input type="text" name="username" /><br />
email: <input type="text" name="email" /><br/>
password:<input type="password" name="password" /><br/>
likedvideos: <input type="text" name="likedvideos" /><br/>
</form>
これを行うとエラーが発生します。 Y?
<form <% @user1,:action => :new, :method => :post %> >
この行は、ユーザnの後にrubyが実行されるとエラーを返します。私は何をしますか ?
Plzは私のファイル名に従って、dトップのリンクにあるpplのファイル名ではありません。 thnx
ERROR
home/vaibhav/MusicDirectory/app/views/user1/user1index.html.erb:46: syntax error, unexpected =>, expecting &. or :: or '[' or '.' ...orm '.freeze; @user1 ,:action=> :new ,:method => :post ;@out... ...^
をあなたの質問を編集して、実際のエラーメッセージを投稿し、何が起こっているかのあなたの説明は少し難しいですしてください理解する。 – guiniveretoo
レール3またはレール5ですか?よくわかりません。 –
Rails 5 srryが修正しました –