嗨,我是 ruby on rails 的新手。
我有两张桌子是Lov_names
和lov_values
。
我的爱人姓名表如下:-
id serial NOT NULL,
name character varying(255) NOT NULL,
description character varying(255),
deleted integer NOT NULL DEFAULT 0,
CONSTRAINT lov_names_pkey PRIMARY KEY (id)
我的爱值表如下:-
id serial NOT NULL,
lov_name_id integer,
lov_value character varying(255) NOT NULL,
sequence integer,
deleted integer NOT NULL DEFAULT 0,
CONSTRAINT lov_values_pkey PRIMARY KEY (id)
从上面可以看出,lov 值引用了 lov 名称
我使用脚手架为他们创建了视图。
lov name 的视图是:-
<% @lov_names.each do |c| %>
<tr>
<td><%= link_to c.id, {:action => 'show', :id => c.id} %> </td>
<td><%= c.name %> </td>
<td><%= c.description %> </td>
<td><%= link_to 'Edit', {:action => 'edit', :id => c.id} %> </td>
<td><%= link_to 'Delete', {:action => 'delete', :id => c.id},
:data => { :confirm => "Are you sure you want to delete this value?" } %></td>
</tr>
<% end %>
</table>
lov值的观点如下:-
<% @lov_values.each do |c| %>
<tr>
<td><%= link_to c.id, {:action => 'show', :id => c.id} %> </td>
<td><%= c.lov_name_id %> </td>
<td><%= c.lov_value %> </td>
<td><%= c.sequence %> </td>
<td><%= link_to 'Edit', {:action => 'edit', :id => c.id} %> </td>
<td><%= link_to 'Delete', {:action => 'delete', :id => c.id},
:data => { :confirm => "Are you sure you want to delete this value?" } %></td>
</tr>
<% end %>
</table>
现在我面临的问题是我想链接两个视图,即当我点击 id 时,Lov names
我应该能够生成相应的lov value for that id
. 此外,我应该能够Lov values
从我创建的视图中添加、编辑和删除该页面中的内容。
有人可以指导我这个。