Displaying 1 result from an estimated 1 matches for "region_id_before_type_cast".
2006 Aug 14
1
What fields_for really for?
...rue
end
In edit.rhtml for SuburbController I need to specify region_id.
There is no region_id in suburb model so first I added these lines to
it:
...
class Suburb < ActiveRecord::Base
belongs_to :district
attr_writer :region_id
def region_id
district.region_id if district
end
def region_id_before_type_cast
region_id
end
validates_numericality_of :region_id, :only_integer => true
end
...
Its all working now but it looks messy! And I need this functionality in
another few places. Obviously I dont want to put this rubbish into other
models!
I recently come across fields_for helper. So I c...