-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathactions.rb
More file actions
executable file
·43 lines (28 loc) · 844 Bytes
/
actions.rb
File metadata and controls
executable file
·43 lines (28 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
get '/' do
@finstagram_posts = FinstagramPost.order(created_at: :desc)
erb(:index)
end
get '/signup' do #if a user navigates to the path
@user = User.new #setup empty @user object
erb(:signup) #render "pp/views/signup.erb"
end
post '/signup' do
# "Form submitted!"
#params.to_s
#grab user input values
email = params[:email]
avatar_url = params[:avatar_url]
username = params[:username]
password = params[:password]
#instntiate and save a User
if email.present? && avatar_url.present? && username.present? && password.present?
#instantiate and save a user
user = User.new({email: email, avatar_url:avatar_url, username: username, password: password})
user.save
#return readable representation of user objectc
escape_html user.inspect
else
#display simple error
"Validation failed"
end
end