Created
September 7, 2012 23:22
-
-
Save tonatiuh/3670657 to your computer and use it in GitHub Desktop.
Error when sending all the vertical form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###app/models/vertical.rb | |
class Vertical < ActiveRecord::Base | |
has_one :parent_relation, foreign_key: "child_id", class_name: "VerticalRelation" | |
has_many :child_relations, foreign_key: "parent_id", class_name: "VerticalRelation" | |
has_one :head_relation, foreign_key: "tail_id", class_name: "VerticalRelation" | |
has_one :tail_relation, foreign_key: "head_id", class_name: "VerticalRelation" | |
has_one :parent, through: :parent_relation | |
has_many :children, through: :child_relations, source: :child | |
has_one :head, through: :head_relation | |
has_one :tail, through: :tail_relation | |
has_and_belongs_to_many :synonyms | |
has_many :portfolios | |
has_many :campaigns | |
accepts_nested_attributes_for :parent_relation, :head_relation, :tail_relation, :child_relations, :synonyms | |
attr_accessible :dispute_expiry, :head, :name, :relevancy_expiry, :tail, :parent, :parent_relation_attributes, :head_relation_attributes, :tail_relation_attributes, :synonym_ids, :synonyms_attributes | |
after_update :expire_vertical_presentations | |
after_create :expire_vertical_presentations | |
before_destroy :expire_vertical_presentations | |
# Expire all cached placement data pages for this vertical | |
def expire_vertical_presentations | |
vertical_id = self.id | |
presentations = Presentation.where(%Q{placements ~ E'"vertical"\\\\s*:\\\\s*#{vertical_id}\\\\s*(,|\})'}).all | |
#Rails.logger.debug("\n\n+++++ Matched #{presentations.count} presentations when modifying a placement for vertical #{vertical_id}\n\n") | |
presentations.collect{|p| p.dig}.uniq.each do | hash | | |
path = Rails.application.routes.url_helpers.placement_data_path(:hash => hash, :format => :js) | |
ActionController::Base.expire_page(path) | |
end | |
end | |
end | |
### The stack error | |
ActiveModel::MassAssignmentSecurity::Error in Admin::VerticalsController#update | |
Can't mass-assign protected attributes: synonym | |
Rails.root: /Users/tonatiuh/tangosource/ContactLogic | |
Application Trace | Framework Trace | Full Trace | |
Request | |
Parameters: | |
{"utf8"=>"✓", | |
"_method"=>"put", | |
"authenticity_token"=>"iPhmkprt/eRrjOvyNrhWuo+yzbmG3wsNYqXK92cGeqY=", | |
"vertical"=>{"name"=>"this is my vertical", | |
"parent_relation_attributes"=>{"parent_id"=>"", | |
"id"=>"7"}, | |
"head_relation_attributes"=>{"head_id"=>"", | |
"id"=>"8"}, | |
"tail_relation_attributes"=>{"tail_id"=>"", | |
"id"=>"9"}, | |
"relevancy_expiry"=>"", | |
"dispute_expiry"=>"", | |
"synonym_ids"=>[""], | |
"synonym"=>{"text"=>"my synonym"}}, | |
"commit"=>"Update Vertical", | |
"id"=>"3"} | |
Show session dump | |
Show env dump | |
Response | |
Headers: | |
None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment