On Martes, 27 de Julio de 2010 22:46:59 Pedro G. escribió:
> Hi,
>
> I understand that I can use record_select_conditions_from_controller
> in order to filter the records that will be shown on record_select. My
> question is: is there any way of filtering this information depending
> on the controller that is invoking record_select
>
> Let's say, for example, that I have three models:
> Book
> Author
> Publisher
>
> And
> Class Author
> has_many :books
>
> Class Publisher
> has_many :books
>
> Class Book
> belongs_to :Author
> belongs_to :Publisher
>
> In this case, I would configure record_select in the
> books_controller.rb
> record_select :per_page => 5, :search_on => 'title'
>
> And I would configure activescaffold in the authors_controller.rb and
> publisher_controllers.rb by introducing the following line in the
> config block
>
> config.columns[:book].form_ui = :record_select
>
> Imagine that I want to filter books differently depending on whether
> I'm invoking record_select from the authors controller or the
> publishers controllers. (very much like
> options_for_association_conditions, where I can establish the
> conditions for a given association)
>
> Is there any way to do this with
> record_select_conditions_from_controller, by passing the invoking
> controller as a parameter or any other means?

Yes, you have to send the current controller as a parameter. As you can see, 
record_select_field accepts a params key in options hash, so putting in your 
column options a params key with :controller => self.controller_path should 
work.

>
> Thanks in advance
> Pedro

-- 
Sergio Cambra .:: entreCables S.L. ::.
Mariana Pineda 23, 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) [email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" 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/activescaffold?hl=en.

Reply via email to