Reputation: 937
I am in the process of validating in ActiveRecord with rails and I had a question. When you're validating something in customer method can you just use the attribute name flat out or do I have to use the "@" symbol as if its an instance I'm handling? So which of the ways below is correct? Thank you very much I appreciate it!
For example:
if(@person.name == "Chris")
end
if(name == "Chris")
Upvotes: 0
Views: 35
Reputation: 50
I think I don't understand well your questions, but I would like to help you. If you are validating into method of Class should be:
def self.validateName(name)
if(name == "Chris")
something ..
end
If you are validating into view
if(@person.name == "Chris")
end
If the name is comming via params to the controller
if(params[:name] == "Chris")
end
I hope help you :)
Upvotes: 1