So now I have such a problem.
ChargeCard >--- TeachingPlace >--- Lecturer
For the purpose of rebinding charge cards from one teaching place to
another I've added to ChargeCard model an addititonal association:
belongs_to :teaching_place
# this needs to ActiveScaffold can display teaching place in charge
cards for moving
belongs_to :teaching_place_for_move, :class_name => 'TeachingPlace',
:foreign_key => 'teaching_place_id'
And :teaching_field is displaying in charge card on update:
class DeptHead::ChargeCardsController < DeptHead::BaseController
active_scaffold do |config|
config.columns = [:jets, :discipline, :lesson_type,
:hours_quantity, :hours_per_week, :weeks_quantity, :groups,
:teaching_place]
config.create.columns.exclude :groups, :hours_quantity, :teaching_place
config.update.columns.exclude :groups, :hours_quantity
config.list.columns.exclude :jets, :teaching_place
config.columns[:discipline].form_ui = :record_select
config.columns[:lesson_type].form_ui = :select
config.columns[:teaching_place].form_ui = :record_select
config.columns[:discipline].clear_link
config.columns[:groups].clear_link
end
end
RecordSelect is confifured this way:
class DeptHead::TeachingPlacesController < DeptHead::BaseController
record_select :search_on => 'lecturers.name', :include => :lecturer
active_scaffold do |config|
config.columns = [:lecturer, :position]
config.columns[:lecturer].form_ui = :record_select
config.columns[:lecturer].clear_link
config.columns[:position].form_ui = :select
config.columns[:lecturer].sort_by :sql => 'lecturers.name'
config.search.columns = :lecturer
config.columns[:lecturer].search_sql = 'lecturers.name'
config.nested.add_link('Карта распределения нагрузки', [:charge_cards])
end
...
Record select field displaying whole list of teaching places but when
I start to fill this field to filter results I get this:
PGError: ERROR: missing FROM-clause entry for table "lecturers"
LINE 1: ...t(*) AS count_all FROM "teaching_places" WHERE (((lecturers....
^
: SELECT count(*) AS count_all FROM "teaching_places" WHERE
(((lecturers.name LIKE 'sadfsadf%')))
ActiveRecord::StatementInvalid (PGError: ERROR: missing FROM-clause
entry for table "lecturers"
LINE 1: ...t(*) AS count_all FROM "teaching_places" WHERE (((lecturers....
^
: SELECT count(*) AS count_all FROM "teaching_places" WHERE
(((lecturers.name LIKE 'sadfsadf%'))) ):
warden (0.10.7) lib/warden/manager.rb:35:in `call'
warden (0.10.7) lib/warden/manager.rb:35:in `call'
warden (0.10.7) lib/warden/manager.rb:34:in `catch'
warden (0.10.7) lib/warden/manager.rb:34:in `call'
haml (3.0.18) rails/./lib/sass/plugin/rack.rb:41:in `call'
pdfkit (0.4.6) lib/pdfkit/middleware.rb:14:in `call'
Can anybody tell me what's the problem?
2010/9/22 Sergio Cambra .:: entreCables S.L. ::. <[email protected]>:
> On Miércoles, 22 de Septiembre de 2010 14:18:07 Andrey Voronkov escribió:
>> Can I add such an association in my ChargeCard model that represents
>> the same belongs_to :teaching_place, but named in other way. I think
>> this will prevent it to appear in active_scaffold_constraints.
>>
>> I'll try something like this tomorrow:
>>
>> belongs_to :teaching_place
>> belongs_to :fake_teaching_place_association, :class_name =>
>> 'TeachingPlace', :foreign_key => 'teaching_place_id'
>>
>> How do you think will this work?
>
> I think it should work for update. For create probably teaching_place_id would
> be overriding by teaching_place association, because constraints are applied
> after set attributes. But constraints aren't applied in update.
>
>>
>> 2010/9/22 Andrey Voronkov <[email protected]>:
>> > class Event < ActiveRecord::Base
>> >
>> > belongs_to :dcp,
>> > :class_name => 'Dcp',
>> > :foreign_key => 'dcp_id'
>> > belongs_to :fcp,
>> > :class_name => 'Fcp',
>> > :foreign_key => 'fcp_id'
>> > belongs_to :dcp_subprogram,
>> > :class_name => 'DcpSubprogram',
>> > :foreign_key => 'dcp_id'
>> > belongs_to :fcp_subprogram,
>> > :class_name => 'FcpSubprogram',
>> > :foreign_key => 'fcp_id'
>> >
>> > ...
>> > end
>> >
>> > Oh I guess I'm understood now. Three other belongs_to are shown when
>> > I'm trying to rebound record on update. So yes AS never shows field
>> > for association he was nested from.
>> >
>> > 2010/9/22 Sergio Cambra .:: entreCables S.L. ::. <[email protected]>:
>> >> On Miércoles, 22 de Septiembre de 2010 12:50:47 Andrey Voronkov escribió:
>> >>> module EventsActiveScaffold
>> >>> def self.included(base)
>> >>> base.class_eval do
>> >>> active_scaffold do |config|
>> >>> ...
>> >>>
>> >>> config.update.columns = [:name, :dcp, :dcp_subprogram, :fcp,
>> >>>
>> >>> :fcp_subprogram]
>> >>>
>> >>> config.columns[:dcp].form_ui = :select
>> >>> config.columns[:dcp_subprogram].form_ui = :select
>> >>> config.columns[:fcp].form_ui = :select
>> >>> config.columns[:fcp_subprogram].form_ui = :select
>> >>>
>> >>> ...
>> >>> end
>> >>> end
>> >>> end
>> >>
>> >> What column is the belongs to association? Is that column displayed when
>> >> you open the form in a nested scaffold?
>> >>
>> >>> 2010/9/22 Sergio Cambra .:: entreCables S.L. ::.
> <[email protected]>:
>> >>> > On Miércoles, 22 de Septiembre de 2010 12:19:13 Andrey Voronkov
> escribió:
>> >>> >> Can I patch my AS branch somehow to get the old behaviour back?
>> >>> >
>> >>> > Nested scaffolds never displayed the associated field. Can you post
>> >>> > configuration from previous project?
>> >>> >
>> >>> >> 2010/9/22 Sergio Cambra .:: entreCables S.L. ::.
>> >>
>> >> <[email protected]>:
>> >>> >> > On Miércoles, 22 de Septiembre de 2010 01:32:32 Andrey Voronkov
>> >>
>> >> escribió:
>> >>> >> >> In my previous project all worked OK. Now I have two models
>> >>> >> >> TeachingPlace ---< ChargeCard and TeachingPlacesController has a
>> >>> >> >> nested link for nested charge cards. The aim is to give ability
>> >>> >> >> to an user to rebind charge cards from one teaching place to
>> >>> >> >> another on charge card update. So the config is:
>> >>> >> >>
>> >>> >> >> class DeptHead::ChargeCardsController < DeptHead::BaseController
>> >>> >> >> active_scaffold do |config|
>> >>> >> >> config.columns = [:teaching_place, :discipline, :jets,
>> >>> >> >>
>> >>> >> >> :lesson_type, :hours_quantity, :groups]
>> >>> >> >>
>> >>> >> >> config.create.columns.exclude :groups
>> >>> >> >> config.update.columns = [:teaching_place, :discipline, :jets,
>> >>> >> >>
>> >>> >> >> :lesson_type, :hours_quantity]
>> >>> >> >>
>> >>> >> >> config.list.columns.exclude :jets
>> >>> >> >> config.show.columns.exclude :jets
>> >>> >> >> config.columns[:discipline].form_ui = :record_select
>> >>> >> >> config.columns[:lesson_type].form_ui = :select
>> >>> >> >> config.columns[:teaching_place].form_ui = :record_select
>> >>> >> >> config.columns[:discipline].clear_link
>> >>> >> >> config.columns[:groups].clear_link
>> >>> >> >> end
>> >>> >> >> end
>> >>> >> >>
>> >>> >> >> but :teaching_place column does not appear in update form and
>> >>> >> >> there is no errors in logs.
>> >>> >> >
>> >>> >> > teaching_place is added to active_scaffold_constraints when you
>> >>> >> > show nested charge_cards and it isn't displayed. You can try to
>> >>> >> > override constraints in a before_filter, although you will have to
>> >>> >> > fill in teaching_place for new charge cards too.
>> >>> >> >
>> >>> >> > --
>> >>> >> > 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.
>> >>> >
>> >>> > --
>> >>> > 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.
>> >>
>> >> --
>> >> 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.
>
> --
> 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.
>
>
--
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.