Skip to content

Commit

Permalink
Added #id that returns nil to play nice with form_for(@presenter)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tammer Saleh committed Jan 21, 2009
1 parent 7916fef commit 395ff81
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/active_presenter/base.rb
Expand Up @@ -59,7 +59,7 @@ def initialize(args = {})

self.attributes = args
end

# Set the attributes of the presentable instances using the type_attribute form (i.e. user_login => 'james')
#
def attributes=(attrs)
Expand Down Expand Up @@ -139,6 +139,11 @@ def update_attributes(attrs)
save
end

def id # :nodoc:
# We override #id to return nil to play nice with form_for(@presenter) in Rails
nil
end

protected
def presented_instances
presented.keys.map { |key| send(key) }
Expand Down
4 changes: 4 additions & 0 deletions test/base_test.rb
@@ -1,6 +1,10 @@
require File.dirname(__FILE__)+'/test_helper'

Expectations do
expect nil do
SignupPresenter.new.id
end

expect :user => User, :account => Account do
SignupPresenter.presented
end
Expand Down

0 comments on commit 395ff81

Please sign in to comment.