inheritance - Rails Changing Polymorphic Type Of An Object -


We have a parent model vehicle that is inherited to create a class car, truck, SUV. In our form, we allow the user to edit the data for a group of vehicles, and there is a selection menu for "type" one of the attributes for each vehicle. The HTML feature has been named the type of vehicle and the actual polymorphic type has been updated in the vehicle model:

  # Go / Set type BC Rail does not allow: Type Type the vehicle in the DRF vehicle selftype type Def vehicle type = (type) self.type = type end  

Our problem is that when we call update_attributes on form data and the current vehicle's Type changed, Rail Pur Nay is calling for verification of class (not new type) which results in errors, what do we have to do when the vehicle_type is changed, then the model is also changed to that new type

Is there any way to do this?


There is an updated action here (in the fleet / more vehicles):

  # PUT / fleet / 1 # PUT /fleet/1.xml def update @fleet = Fleet.find (params [: id]) response_to do | Format | If @Fleet.update_aditiss (PARAMAS [: Fleet]) Flash [: Notice] = 'Vehicle Fleet was updated successfully.' Format.html {Render: Action => "Edit"} format.xml {head: ok} and format.html {rendere: action = & gt; "Edit"} format.xml {render: xml = & gt; @flit Errors,: Status = & gt; : Unprocessable_entity} End End End  

There are fleets:

  class fleet & lt; ActiveRecord :: Base is has_many: vehicle, dependent => : Delete, command = & gt; 'Status ASC' accepts for___ATV: vehicle,: reject_If = & gt; Proc {| Attrs | | Attrs ['name']. Empty? } ,: Allow_destroy = & gt; You can use a factory method to create the right type of vehicle, then specify  

Features.

DTF vehicle. Feature (type) type.Installation. NYEE

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -