On Miércoles, 23 de Junio de 2010 06:48:24 Andrey Voronkov escribió:
> I have two models:
>
> BuildingObject < ActiveRecord::Base
> has_one: object_card
>
> def base_price_date
> self.object_card.base_price_date
> end
> end
>
> ObjectCard < ActiveRecord::Base
> belongs_to: object_card
> end
>
> On create/update a building object I need to set only year from
> base_price_date. So When I create/update a building_object I have a subform
> to input object card values
> I have defined base_price_date_form_column with :discard_month => true in
> ObjectCardsHelper, in Building Object update/create form nothing happens -
> all 3 fields for day, month, year.
If you want a method from ObjectCardsHelper is used in
BuildingObjectsController, add helper :object_cards in the controller, or
define that method in BuildingObjectsHelper (as you have done).
> When I define this method in
> BuildingObjectsHelper:
> def base_price_date_form_column(record, input_name)
> date_select record, :base_price_date, :name => input_name,
>
> :start_year => 1990, :end_year => Time.now.year, :discard_month =>
>
> true
> end
> there are one field for year only, but the request on submitting is:
> "record"=>{"base_price_date(3i)"=>"6", "name"=>" Очистные сооружения в пос.
> Новобурейский мощностью до 3200 м3/сут. В составе зоны затопления Бурейской
> ГЭС - Реконструкция очистных сооружений п. Новобурейский. II очередь",
> "fcp_subprogram"=>"", "dcp"=>"", "object_card"=>{"power"=>"", "id"=>"61",
> "cost_in_base_prices"=>"1 000 000.0"}, "dcp_subprogram"=>"", "fcp"=>"2",
> "base_price_date(1i)"=>"1993", "base_price_date(2i)"=>"4"}}
Second argument in helper override is options hash in master branch, so your
name won't be set right. Change it with:
def base_price_date_form_column(record, options)
date_select record, :base_price_date, options.merge(:start_year => 1990,
:end_year => Time.now.year, :discard_month => true)
end
--
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.