Access flash from a model class?


#1

I have a method that returns either a comment stored in the flash (if it
exists) or a new comment. It works when I put it in my application
controller:

def preform_comment
if flash[:badcomment].nil?
comment = Comment.new
return comment
else
return flash[:badcomment]
end
end

However it would be cleaner to put this in the Comment model, so I
tried:

def self.preform
if flash[:badcomment].nil?
comment = Comment.new
return comment
else
return flash[:badcomment]
end
end

But then I get the error

undefined local variable or method `flash’ for Comment:Class

Is there another way to access the flash from the model?


#2

Why woud it be cleaner???

Does your model know about flash?? does your model know http???

Flash is strictly view and not model…

Keep it in the controller

On Tuesday, March 07, 2006, at 7:56 PM, Filip G. wrote:

end
return flash[:badcomment]
Posted via http://www.ruby-forum.com/.


Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails

Mikkel B.

www.strongside.dk - Football Portal(DK)
nflfeed.helenius.org - Football News(DK)
ting.minline.dk - Buy Old Stuff!(DK)