Hi
First let me mention that i am new to rails.
In my application there is a form for entering product details for
bidding. I have a view and all the data is entered into a form.
In the database there is a unique_id which is generated for each
product(this is for internal use within the company). The unique id is
generated using data from 2 fields and another generated number. all 3
needs to be concatenated.
My questions:
where is the best place to perform the operation.
I assume it is in the controller
How do i do it. How do I take the form data and concatenate all the
values, so that the unique id is inserted into the database.
Is this best done in model than in controller?
Is it possible to retrieve some data from the db according to a field?
Eg: let us assume foo, bar and unique_ident as above.
now bar contains a primary key of a table which contains actual data.
foo = 137874
bar = 1
unique_ident = ss137874, because according to table
bar_table
id value
1 ss
2 dd
now can a retrieve the value according to the value of bar which is
given in the view?
ok. let me start from the begining.
3 fields of concern here are product_code, product_category,
unique_ident.
In the view product_category is selected through a dropdown. Its values
are integer, which is id of the category table.
given below is sample values of category table
categories
id category category_code
1 electronics el
2 cars ca
now, sample values input by the user
product_code : 333
product_category : 2
in this case the unique_ident should be product_code + the category_code
of the corresponding product_category
i.e: ca333