On Tue, Jul 14, 2009 at 2:07 AM, Sijo Kg
<[email protected]>wrote:

>
> Hi
>   I have model Role as
>
> validates_presence_of :name
> validates_presence_of :description
> validates_format_of :name, :with => /[,]/
>
> And the test to check format as
>    setup do
>      @role = Factory(:role) #gives :name=>'role1' description =>
> 'testdescript'
>    end
>    should "validate format of role name" do
>      assert_valid(@org_role)
>    end
>
> But when running test  get error
>
> test: role should have correct name format. (RoleTest):
> ActiveRecord::RecordInvalid: Validation failed: Role name is invalid
>
>
> But when I comment  validates_format_of above everything work ok I cant
> figure out where the error is Actually I need role name should not
> contain any commas  Please help
>
> Thanks in advance
> Sijo


Sijo, what is the correct format for a name?  In any case, your regular
expression
says that the format for the name should be a comma.  Thus, you might want
to
rework your regular expression so that it supports the correct naming
format.

Good luck,

-Conrad

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to