Skip to content

Commit 09bfdc4

Browse files
committed
create a new method to insert a sample user to table
1 parent 9963733 commit 09bfdc4

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

app/controllers/homes_controller.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,20 @@ def index
44
@users = User.all
55
render json: @users, status: :ok
66
end
7+
8+
def new
9+
object = User.new(
10+
:ip => "192.168.1.50",
11+
:key_user => "key1",
12+
:key_ip => "key2",
13+
:key_license => "key3",
14+
:datetime => 123,
15+
:datetime_expire => nil,
16+
:use_first => nil,
17+
:use_last => nil,
18+
:is_active => 1
19+
)
20+
object.save
21+
end
22+
723
end

config/routes.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
Rails.application.routes.draw do
22
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
33
root to: 'homes#index'
4+
get 'new', to: 'homes#new'
5+
46
end

db/development.sqlite3

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)