我如何从数据库中获取价值? [英] How do I get a value from the database?

查看:130
本文介绍了我如何从数据库中获取价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用Ruby on Rails开发Web应用程序.我有一个供工人使用的桌子和一个供职系使用的桌子.将新工作程序添加到系统后,表单如下所示:

I am currently developing a web application using Ruby on Rails. I have a table for workers and a table for grades. When a new worker is added to the system the form looks as follows:

<h1>New worker</h1>

<% form_for(@worker) do |f| %>
  <%= f.error_messages %>

  <p>
    <%= f.label :name %><br />
    <%= f.text_field :name %>
  </p>
  <p>
    <%= f.label :grade %><br />
    <%= f.text_field :grade %>
  </p>
  <p>
    <%= f.label :remaining_days %><br />
    <%= f.text_field :remaining_days %>
  </p>
  <p>
    <%= f.submit 'Create' %>
  </p>
<% end %>

<%= link_to 'Back', workers_path %>



我的成绩表包含两列,分别是成绩和no_of_days.

添加新工作人员时,我需要根据所选的等级自动添加no_of_days.



My grades table contains two columns which are grade and no_of_days.

When a new worker is being added, I need the no_of_days to be added automatically depending on the grade selected.

推荐答案

很好的参考网址:http://www.troubleshooters.com/codecorn/ruby/database/index.htm [
Nice reference at: http://www.troubleshooters.com/codecorn/ruby/database/index.htm[^]


这篇关于我如何从数据库中获取价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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