如何在rails中的ruby中的sqlite数据库中插入视图的绑定值 [英] how to insert binded value of view in sqlite database in ruby on rails

查看:66
本文介绍了如何在rails中的ruby中的sqlite数据库中插入视图的绑定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Ruby On Rails的新手,我想将IP地址和当前时间插入数据库。我已经在视图上显示了IP地址和时间,现在我想在sqlite上插入这些值



我的查看代码:



<%= form_for(@emps)do | f | %>

I am a newbie in Ruby On Rails and i want to insert IP address and current time to database. I have shown IP address and time on view,now i want to insert these values on sqlite

My view code:

<%= form_for(@emps) do |f| %>

IP:   <%= f.label require 'socket'
        ip=Socket.ip_address_list.detect{|intf| intf.ipv4_private?}
        ip.ip_address  %><br>


 Current Time:
        <%= f.label t = Time.now
        t.strftime("%I:%M%p")  %>

  <%= f.submit  id: 'checkin', name:'action', value:'CheckIn'%>





OnController:





OnController:

def index
      @emps= Ems.new
      @emps.save
 end









i想在数据库sqlite中插入这些ip和time。请帮帮我





i want to insert these ip and time in database sqlite. please help me

推荐答案

这篇关于如何在rails中的ruby中的sqlite数据库中插入视图的绑定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆