Try
fields do
product_name :string, :name => true
...
end
On 15 Dec 2008, at 19:50, Hobo_Fan wrote:
>
> Hi All,
>
> Can someone point me to a right direction on how to customize the
> default belongs_to drop down list? One of my edit form, license
> belongs to both product and client models. I have a name field in
> product model; however, the drop down in the license assignment page
> only display the product table id and client table id. Is there a way
> to have the drop down to display product_name and client_name instead
> of id?
>
> I have three models: client, license, and product
>
> class Client < ActiveRecord::Base
>
> hobo_model # Don't put anything above this
>
> fields do
> first_name :string
> last_name :string
> department :string
> timestamps
> end
>
> has_many :licenses
> has_many :products, :through => :licenses
>
> *****
> class License < ActiveRecord::Base
>
> hobo_model # Don't put anything above this
>
> fields do
> license_type :string
> quanty :integer
> key :string
> expiration_date :date
> timestamps
> end
>
> belongs_to :product
> belongs_to :client
>
> ****
> class Product < ActiveRecord::Base
>
> hobo_model # Don't put anything above this
>
> fields do
> product_name :string
> engine_version :string
> platform :string
> feature :text
> timestamps
> end
>
> has_many :licenses
> has_many :clients, :through => :licenses
>
>
>
> Below is what is currently displayed on browser, where is only shows
> product_id. Is possible to display product_name instead?
>
> <tr>
> <th>
> Product
> </th>
> <td>
> <select class="product license-product input belongs-to" name="license
> [product_id]">
> <option value="1" selected="selected">Product 1</option>
> <option value="2">Product 2</option>
> </select>
> </td>
> </tr>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---