Skip to content

Instantly share code, notes, and snippets.

@benaskins
Created September 14, 2009 05:14
Show Gist options
  • Save benaskins/186520 to your computer and use it in GitHub Desktop.
Save benaskins/186520 to your computer and use it in GitHub Desktop.
TypeError in Admin/stylesheetsController#create
can't modify frozen hash
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/attribute_methods.rb:313:in `[]='
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/attribute_methods.rb:313:in `write_attribute_without_dirty'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/dirty.rb:139:in `write_attribute'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/timestamp.rb:33:in `touch'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/associations/association_proxy.rb:221:in `send'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/associations/association_proxy.rb:221:in `method_missing'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/associations.rb:1380:in `belongs_to_touch_after_save_or_destroy_for_site'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:178:in `send'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:178:in `evaluate_method'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:166:in `call'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:93:in `run'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:92:in `each'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:92:in `send'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:92:in `run'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:276:in `run_callbacks'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/callbacks.rb:344:in `callback'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/callbacks.rb:251:in `create_or_update'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:2555:in `save_without_validation!'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/validations.rb:1088:in `save_without_dirty!'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/dirty.rb:87:in `save_without_transactions!'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/transactions.rb:200:in `save!'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/transactions.rb:182:in `transaction'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/transactions.rb:200:in `save!'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/transactions.rb:208:in `rollback_active_record_state!'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/transactions.rb:200:in `save!'
/Users/benj/Development/client_projects/wx/app/controllers/admin/stylesheets_controller.rb:14:in `create'
class Site < ActiveRecord::Base
has_many :stylesheets, :dependent => :destroy
belongs_to :active_stylesheet, :class_name => "Stylesheet", :foreign_key => "active_stylesheet_id"
after_save :refresh_site_cache
protected
def refresh_site_cache
Rails.cache.write(cache_key, reload(:include => [:active_stylesheet, :active_icon_set, :pages]))
end
def self.cache_key(domain_name)
"site:#{domain_name}"
end
def cache_key
Site.cache_key(self.domain_name)
end
end
class Stylesheet < ActiveRecord::Base
belongs_to :site, :touch => true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment