On 19 February 2015 at 08:44, Maarten Van Essen <
li...@ruby-forum.com> wrote:
> I am a beginner in Ruby on Rails.
>
> I would like to make the following database model:
>
> Package (has_many packagelines)
> Packageline (belongs_to package)
>
> The package line can be one of 3 things: entity, item or service, so I
> would like to have a line type with the options entity, item or service.
> I also want a field where I store the foreign key. The problem is that
> the foreign key is dependent on what is selected in the line type field.
Before you attempt to solve such issues I would make sure you have a
good understanding of the basics of Rails, as you may well decide the
above is not the best way to solve the problem. I suggest you first
work right through a good tutorial such as
railstutorial.org (which is
free to use online) including doing all the exercises. Then
reconsider your problem and come back with further questions if
necessary.
Colin