Created
October 10, 2009 21:29
-
-
Save billsaysthis/207144 to your computer and use it in GitHub Desktop.
before save attr weirdness
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
from script/console production | |
>> u = Service.find(37) | |
=> #<Service id: 37, user_id: 9, url: "http://www.example.com", tiny_url: "", name: "TipMe", email: "", currency_id: 840, timezone_id: 140, locale: "en_US", verification_attempt_at: nil, verified_at: nil, tax_registration: nil, npo_registration: nil, flags: 0, created_at: "2009-02-15 22:29:50", updated_at: "2009-10-10 20:20:37", color: nil, paypal_id: "", paypal_email: "", contributors_count: 14, description: "Just give us some tips! Updated"> | |
>> u.description | |
=> "Just give us some tips! Updated" | |
Model: | |
require 'open-uri' | |
require 'hpricot' | |
# Commented out by Bill, 2009-08-27 | |
# require 'twitter' | |
require 'net/http' | |
require 'uri' | |
class Service < ActiveRecord::Base | |
belongs_to :user | |
... | |
named_scope :top_contributors, :order => 'contributors_count DESC', :limit => 15 | |
named_scope :by_user, lambda {|uid| {:conditions => {:user_id => uid}}} | |
validates_presence_of :name, :url | |
... | |
attr_accessible :description, :contributors_count | |
before_save { |record| (record.verification_attempt_at = record.verified_at = nil; record.tiny_url = '') if record.url_changed? } | |
# Set contributors_count default to 0 | |
def initialize(attributes=nil) | |
super({:contributors_count => 0}.merge(attributes || {})) | |
end | |
... | |
def access_authorized?(user) | |
user.try(:id) == self.user_id | |
end | |
... | |
Error stack: | |
ActionView::TemplateError (undefined method `description' for #<Service:0xb5f5e1f4>) on line #21 of app/views/recipient/_site_form.html.erb: | |
18: <label for='service_paypal_email'>Paypal Account Email:</label><br/><%= f.text_field :paypal_email %> | |
19: </div> | |
20: <div class='fieldTag'> | |
21: <label for='service_description'>Description:</label><br/><%= f.text_area :description, :rows => 4, :cols => 26 %> | |
22: </div> | |
23: <div class='fieldTag'> | |
24: <label for='user_logo'>Your logo:</label><br/> | |
app/views/recipient/_site_form.html.erb:21 | |
app/views/recipient/_site_form.html.erb:2 | |
app/views/recipient/edit.html.erb:6 | |
passenger (2.2.5) lib/phusion_passenger/rack/request_handler.rb:95:in `process_request' | |
passenger (2.2.5) lib/phusion_passenger/abstract_request_handler.rb:207:in `main_loop' | |
passenger (2.2.5) lib/phusion_passenger/railz/application_spawner.rb:378:in `start_request_handler' | |
passenger (2.2.5) lib/phusion_passenger/railz/application_spawner.rb:336:in `handle_spawn_application' | |
passenger (2.2.5) lib/phusion_passenger/utils.rb:183:in `safe_fork' | |
passenger (2.2.5) lib/phusion_passenger/railz/application_spawner.rb:334:in `handle_spawn_application' | |
passenger (2.2.5) lib/phusion_passenger/abstract_server.rb:352:in `__send__' | |
passenger (2.2.5) lib/phusion_passenger/abstract_server.rb:352:in `main_loop' | |
passenger (2.2.5) lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously' | |
passenger (2.2.5) lib/phusion_passenger/abstract_server.rb:163:in `start' | |
passenger (2.2.5) lib/phusion_passenger/railz/application_spawner.rb:213:in `start' | |
passenger (2.2.5) lib/phusion_passenger/spawn_manager.rb:262:in `spawn_rails_application' | |
passenger (2.2.5) lib/phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add' | |
passenger (2.2.5) lib/phusion_passenger/spawn_manager.rb:256:in `spawn_rails_application' | |
passenger (2.2.5) lib/phusion_passenger/abstract_server_collection.rb:80:in `synchronize' | |
passenger (2.2.5) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize' | |
passenger (2.2.5) lib/phusion_passenger/spawn_manager.rb:255:in `spawn_rails_application' | |
passenger (2.2.5) lib/phusion_passenger/spawn_manager.rb:154:in `spawn_application' | |
passenger (2.2.5) lib/phusion_passenger/spawn_manager.rb:287:in `handle_spawn_application' | |
passenger (2.2.5) lib/phusion_passenger/abstract_server.rb:352:in `__send__' | |
passenger (2.2.5) lib/phusion_passenger/abstract_server.rb:352:in `main_loop' | |
passenger (2.2.5) lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously' | |
500 displayed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment