On Sat, Jan 10, 2009 at 3:33 AM, Tom Locke <[email protected]> wrote:
>> 2) Have a path field but declare that to be the name.  I thought
>> this would work.
>>
>>   fields do
>>     path       :string, :name => true
>>   end
>>
>>  => undefined method `name' for #<Clip:0xb60de5c4>
>
> That seems wrong too. Again - can you post the trace?

Well wtf.  Now it works perfectly.  I found some bad data in my
database last night and fixed it -- that probably explains the
failure.  Sorry for the noise.


> I think select-many should be able to work without the model having a
> name, although both the docs and the code seem to disagree with me,
> but what do they know? Can you post the full trace Scott.

5) No name field at all:

  fields do
    path       :string
  end

The full trace of the failure is below.

It only fails when I add a Clip to an Episode and then hit Save.  It
doesn't happen when I add an Episode to a Clip, probably because
Episode has a name field and Clip doesn't.

I've included the relevant models and controllers, mildly redacted, at
the very end.  The line numbers in episode.rb and clip.rb might not
match exactly with the trace.

    - Scott



Processing EpisodesController#update (for 127.0.0.1 at 2009-01-10
14:59:24) [PUT]
  Parameters: {"page_path"=>"episodes/edit",
"authenticity_token"=>"ba0894ba9cedf7ebb7b19666f1c63e2728e4f15b",
"id"=>"1-game-vs-red-wings", "episode"=>{"name"=>"Game vs. Red Wings",
"thumbnail"=>"", "number"=>"2", "clips"=>[""], "network"=>"",
"description"=>"Sharks take on the Red Wings.",
"released"=>{"month"=>"1", "second"=>"00", "minute"=>"27",
"hour"=>"07", "day"=>"8", "year"=>"2009"}, "networkEpisodeID"=>""}}
User Load (0.7ms)  SELECT * FROM "users" WHERE ("users"."id" = 1)
Episode Load (0.6ms)  SELECT * FROM "episodes" WHERE ("episodes"."id" = 1)


Hobo::Model::NoNameError (Model Clip has no name attribute):
    /vendor/plugins/hobo/hobo/lib/hobo/model.rb:143:in `named'
    /vendor/plugins/hobo/hobo/lib/hobo/scopes/named_scope_extensions.rb:20:in
`send'
    /vendor/plugins/hobo/hobo/lib/hobo/scopes/named_scope_extensions.rb:20:in
`method_missing'
    /vendor/rails/activerecord/lib/active_record/base.rb:2005:in `with_scope'
    (__DELEGATION__):2:in `__send__'
    (__DELEGATION__):2:in `with_scope'
    /vendor/plugins/hobo/hobo/lib/hobo/scopes/named_scope_extensions.rb:19:in
`method_missing'
    /vendor/plugins/hobo/hobo/lib/hobo/accessible_associations.rb:67:in
`find_by_name_or_id'
    /vendor/plugins/hobo/hobo/lib/hobo/accessible_associations.rb:30:in
`find_or_create_and_update'
    /vendor/plugins/hobo/hobo/lib/hobo/accessible_associations.rb:13:in
`prepare_has_many_assignment'
    /vendor/plugins/hobo/hobo/lib/hobo/accessible_associations.rb:11:in `map!'
    /vendor/plugins/hobo/hobo/lib/hobo/accessible_associations.rb:11:in
`prepare_has_many_assignment'
    /vendor/plugins/hobo/hobo/lib/hobo/accessible_associations.rb:91:in `clips='
    /vendor/rails/activerecord/lib/active_record/base.rb:2589:in `send'
    /vendor/rails/activerecord/lib/active_record/base.rb:2589:in
`attributes_without_hobo_type_conversion='
    /vendor/rails/activerecord/lib/active_record/base.rb:2585:in `each'
    /vendor/rails/activerecord/lib/active_record/base.rb:2585:in
`attributes_without_hobo_type_conversion='
    /vendor/plugins/hobo/hobo/lib/hobo/model.rb:430:in `send'
    /vendor/plugins/hobo/hobo/lib/hobo/model.rb:430:in `attributes='
    /vendor/plugins/hobo/hobo/lib/hobo/permissions.rb:144:in
`user_update_attributes'
    /vendor/plugins/hobo/hobo/lib/hobo/permissions.rb:121:in `with_acting_user'
    /vendor/plugins/hobo/hobo/lib/hobo/permissions.rb:143:in
`user_update_attributes'
    /vendor/plugins/hobo/hobo/lib/hobo/model_controller.rb:552:in `hobo_update'
    /vendor/plugins/hobo/hobo/lib/hobo/model_controller.rb:158:in `update'
    /vendor/rails/actionpack/lib/action_controller/base.rb:1253:in `send'
    /vendor/rails/actionpack/lib/action_controller/base.rb:1253:in
`perform_action_without_filters'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:617:in
`call_filters'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:638:in
`run_before_filters'
    /vendor/plugins/hobo/hobo/lib/hobo/controller.rb:22:in `call'
    /vendor/plugins/hobo/hobo/lib/hobo/controller.rb:22:in `included_in_class'
    /vendor/rails/activesupport/lib/active_support/callbacks.rb:182:in `call'
    /vendor/rails/activesupport/lib/active_support/callbacks.rb:182:in
`evaluate_method'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:184:in `call'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:635:in
`run_before_filters'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:615:in
`call_filters'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:610:in
`perform_action_without_benchmark'
    /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
    /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
    /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
    /vendor/rails/actionpack/lib/action_controller/rescue.rb:136:in
`perform_action_without_caching'
    /vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:13:in
`perform_action'
    
/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in
`cache'
    /vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'
    /vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:in
`perform_action'
    /vendor/rails/actionpack/lib/action_controller/base.rb:524:in `send'
    /vendor/rails/actionpack/lib/action_controller/base.rb:524:in
`process_without_filters'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:606:in
`process_without_session_management_support'
    /vendor/rails/actionpack/lib/action_controller/session_management.rb:134:in
`process'
    /vendor/rails/actionpack/lib/action_controller/base.rb:392:in `process'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:183:in
`handle_request'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:110:in
`dispatch_unlocked'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:123:in
`dispatch'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:122:in
`synchronize'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:122:in
`dispatch'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:132:in
`dispatch_cgi'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:39:in
`dispatch'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:76:in
`process'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in
`synchronize'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in
`process'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in
`process_client'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in
`process_client'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in
`run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in
`each'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in
`run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in
`run'
    /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
    /vendor/rails/activesupport/lib/active_support/dependencies.rb:142:in
`load_without_new_constant_marking'
    /vendor/rails/activesupport/lib/active_support/dependencies.rb:142:in `load'
    /vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in
`new_constants_in'
    /vendor/rails/activesupport/lib/active_support/dependencies.rb:142:in `load'
    /vendor/rails/railties/lib/commands/servers/mongrel.rb:64
    /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
    /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    /vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in
`require'
    /vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in
`new_constants_in'
    /vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in
`require'
    /vendor/rails/railties/lib/commands/server.rb:49
    /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
    /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    ./script/server:3
    -e:2:in `load'
    -e:2

Rendered 
/home/bronson/ws-backend/backend/vendor/rails/actionpack/lib/action_controller/templates/rescues/_trace
(170.0ms)
Rendered 
/home/bronson/ws-backend/backend/vendor/rails/actionpack/lib/action_controller/templates/rescues/_request_and_response
(1.7ms)
Rendering 
/home/bronson/ws-backend/backend/vendor/rails/actionpack/lib/action_controller/templates/rescues/layout.erb
(internal_server_error)


class Clip < ActiveRecord::Base

  hobo_model # Don't put anything above this

  fields do
    path       :string
    timestamps
  end

  has_many :episode_clips, :dependent => :destroy
  has_many :episodes, :through => :episode_clips, :accessible => true

  validates_uniqueness_of :path

  # --- Permissions --- #

  def create_permitted?
    acting_user.administrator?
  end

  def update_permitted?
    return false unless none_changed? :episode
    acting_user.administrator?
  end

  def destroy_permitted?
    acting_user.administrator?
  end

  def view_permitted?(field)
    true
  end

end



class Episode < ActiveRecord::Base

  hobo_model # Don't put anything above this

  fields do
    name             :string
    released         :datetime
    timestamps
  end

  belongs_to :season
  has_many :episode_clips, :dependent => :destroy
  has_many :clips, :through => :episode_clips, :accessible => true

  validates_uniqueness_of :number, :scope => :season_id
  validates_presence_of :name, :season

  # --- Permissions --- #

  def create_permitted?
    acting_user.administrator?
  end

  def update_permitted?
    return false unless none_changed? :season
    acting_user.administrator?
  end

  def destroy_permitted?
    acting_user.administrator?
  end

  def view_permitted?(field)
    true
  end

end


class ClipsController < ApplicationController

  hobo_model_controller

  auto_actions :all, :except => :index

end


class EpisodesController < ApplicationController

  hobo_model_controller

  auto_actions :all, :except => :index
  auto_actions_for :season, [:new, :create]

end

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to