Joshua Muheim
2006-Mar-24 09:49 UTC
[Rails] validates... :if => Proc.new{...} does not find a method!
Hi all
I wanted to use the following validation in my model Party:
validates_presence_of :organisator_name,
:if => Proc.new{ member.organisators.empty? }
I have written the member method in the ApplicationController:
class ApplicationController < ActionController::Base
def member
session[:member]
end
end
But it does not seem to be known by the Party Model...
Any help, please? :-)
Greetings,
Josh
--
Posted via http://www.ruby-forum.com/.
Joshua Muheim
2006-Mar-24 12:38 UTC
[Rails] Re: validates... :if => Proc.new{...} does not find a method
Joshua Muheim wrote:> Hi all > > I wanted to use the following validation in my model Party: > > validates_presence_of :organisator_name, > :if => Proc.new{ member.organisators.empty? } > > I have written the member method in the ApplicationController: > > class ApplicationController < ActionController::Base > def member > session[:member] > end > end > > But it does not seem to be known by the Party Model... > > Any help, please? :-) > > Greetings, > JoshOK, I found the problem now. The models can''t know the method member, because it''s only declarated in the controllers... How can I import this method into the models? Thanks for help. -- Posted via http://www.ruby-forum.com/.