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?
on 2006-03-07 19:56
on 2006-03-07 20:28
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 Godsmurf wrote: > end > return flash[:badcomment] >Posted via http://www.ruby-forum.com/. >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/rails Mikkel Bruun www.strongside.dk - Football Portal(DK) nflfeed.helenius.org - Football News(DK) ting.minline.dk - Buy Old Stuff!(DK)