2009/6/26 Rachel Nichol <[email protected]>:
>
> <!-- this works but it is not correct. i should be passing
> category['wsc_uid_pk'] to controller and using controller to call model... -->
> <%= select("wsc_uid"+category['wsc_uid_pk'].to_s, "id",
> Customer.list_web_serv_types(category['wsc_uid_pk']).map {|u|
> [u['wbt_description'], u['wbt_uid_pk']]}) %>
> <!-- this works but it is not correct. i should be passing
> category['wsc_uid_pk'] to controller and using controller to call model... -->
There is no reason why you should not call model methods from the
view. To improve the modularity however I would suggest providing a
Customer model method called select_box_values or whatever conveys the
right impression to you when you read the code. This method contains
the code that you have in your select statement. Then instead of your
code Customer.list_......map{....} you just have
Customer.select_box_values. Make sure it always returns something
which will be valid in the view however (even in unusual conditions)
so that you do not need any logic in the view.
If you still wish to move this our of the view then in the controller
which invokes this view put
@select_box_values = Controller.select_box_values
and use @select_box_values in the view.
Colin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" 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/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---