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? :slight_smile:

Greetings,
Josh

Joshua M. 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? :slight_smile:

Greetings,
Josh

OK, 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.