@kirinri posted * Nice article --Qiita *, so let's get on it.
main.rb
post '/destroy_user' do
Todos.where('users_id = ?', params[:users_id]).destroy_all
Users.find(params[:users_id]).destroy
redirect to('/')
end
ʻActive record` is nice because you don't have to write SQL.
style.css
.user_btn {
height: 28px;
background-color: #FFAD90;
border-style: none;
border-radius: 5px;
}
~~ The last 3 lines ~~ The last line is rounded Thank you to @scivola.
If you delete a user, it will not be reloaded and the deleted user will remain in the drop-down list. If you add it to the list as that user, you will get an exception.
main.rb
post '/create_todo' do
begin
Todos.create(body: params[:body],users_id: params[:users_id])
rescue => e
end
redirect to('/')
end
I've added exception handling, but I don't think it's a compliment because it's just through.
Referenced site
Recommended Posts