开发者

Rails how to add addtional info to columns ? Complicated problem

开发者 https://www.devze.com 2023-03-27 05:52 出处:网络
I want to be able to add additional information to some columns. I have tho开发者_如何学编程ught making a button \"Add additional info\" in my new form to each input field with some Jquery.

I want to be able to add additional information to some columns. I have tho开发者_如何学编程ught making a button "Add additional info" in my new form to each input field with some Jquery.

But how should I store this additional info? I have thought about creating a table named addinfos and store following: columninfo - The information added to the column

But it will not work because how should I make an association to the column?

UPDATE EDIT: Example I have a regular form:

<%= simple_form_for [@example], :html => { :multipart => true } do |f| %>
        <%= f.input :name, :label => 'Navn' %>
        <%= f.input :customers, :label => 'Customers' %>
<% end %>

The customers column is a integer. Example the there are 400.000 customers, but it is all over the world therefor I want to add this information to the column.

Example in the view:

Rails how to add addtional info to columns ? Complicated problem

When the user hover over the icon the text "All over the world" would appear (Tooltip).

I know how to make the tooltip and all the other stuff in view. But not how to store this data.

I think I have 2 options to do this:

  1. Make an extra column for each column in the table. Example customersinfo, nameinfo which all would be varchar.

  2. Create an new table named information which would have 1 column for each column in the example table. customersinfo, nameinfo, off course varchar. And example table would has_one :information, and information belongs_to :example

0

精彩评论

暂无评论...
验证码 换一张
取 消