Given the following:
class WebsitesController < ApplicationController
Customer does not have identifiers for these models
A request that is sent only has names , but not ids .
And the following models
class Website < ActiveRecord::Base serialize :website_errors attr_accessible :plugins_attributes has_many :plugins accepts_nested_attributes_for :plugins end class Plugin < ActiveRecord::Base belongs_to :website end
When I make a POST request to /websites/save.json , the Website updated correctly if it exists, but the Plugins that it owns always get recreated, causing duplicate content in the database. Why is this happening? I am redirecting to the update action that calls update_attributes , so how could it be that it is not updating it? I believe this is because no identifier is specified with the request.
Can I make a Controller to listen on plugin_name instead of plugin_id ?
ruby-on-rails activerecord ruby-on-rails-3
tolgap
source share