vendredi 18 novembre 2016

Rails 3 : How to insert Record in Database using Rails(HTML5)

NOTE I HAVE ALREADY READ THIS : Rails 3 : How to insert Record in Database using Rails

I am using Rails 3 .

Please let me know how can i insert a Record in the Database .

I am uisng MYSQL , and below is my Table structure to be correct schema.rb in db folder

 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

This is my Controller file user1_controller.rb

 class User1Controller < ApplicationController
 def user1index
 end

This is my Model file alluser.rb

class Alluser < ApplicationRecord
end

This is my view file under \app\views\user1\user1index.html.erb

 <form <% @student,: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>

If i do this i get an error . Y ?

<form <% @user1,:action => :new, :method => :post %> >

this line gives me an error says ruby expected after user n after :action n after :method . What do i do ?

Plz help according to my file names n not the file names of ppl in the link on d top. THNX

Aucun commentaire:

Enregistrer un commentaire