I have a partial form "empresa". In new.rhtml of "empresa",
I call the
partial form of "usuario". Well, it is happening the following: When
save empresa, and stop in validates, as much in "empresa" how much
"usuario", appear only error message of "empresa", and not
of "usuario".
Because this happening?
ps1.: I use flash_message instead of flash[:notice]
ps2.: The "validates" of "usuario" is functioning, does not
only appear
msg. If save only usuario, in new.rhtml of "usuario", the msg`s
appearl,
only when call in partial form of "empresa"
_form Empresa
-----------------------------
<%= error_messages_for ''empresa'' %>
<%= error_messages_for ''usuario'' %>
<%= flash_message %>
<!--[form:empresa]-->
<table>
<tr>
<td><label for="empresa_razao_social">Razão
social:</label></td>
<td><%= text_field :empresa, :razao_social, :size => 50,
:maxlength
=> 50 %></td>
</tr>
<tr>
<td><label for="empresa_nome_fantasia">Nome
fantasia:</label></td>
<td><%= text_field :empresa, :nome_fantasia, :size => 50,
:maxlength
=> 50 %></td>
</tr>
(....)
_form Usuario
-------------------------------
<%= error_messages_for ''usuario'' %>
<%= javascript_include_tag ''forms'' %>
<%= stylesheet_link_tag ''componentes'' %>
<%= flash_message %>
<!--[form:usuario]-->
<table>
<tr>
<td><label>Nome:</label></td>
<td><%= text_field :usuario, :nome %></td>
</tr>
<tr>
<td><label>E-Mail:</label></td>
<td><%= text_field :usuario, :email %></td>
</tr>
(....)
new.rhtml
------------------------------
<h2>Nova Empresa</h2>
<%= form_remote_tag(:update => ''aux_div'',
:url => {:action => ''create''},
:success => visual_effect(:highlight, "fundo"),
:complete =>
"centraliza(''view'')")%>
<%= render :partial => ''form'' %>
<%= render :partial => ''/usuarios/form''%>
<p>
<label>-----------------------------------------------------------</label>
</p>
<%= submit_tag "Salvar", :class => ''botao2''
%><%= link_to ''Cancelar'',
{:controller => ''login'', :action =>
''index''}, :class => ''botao2''%>
<%= end_form_tag %>
model Usuario
--------------------------------------
class Usuario < ActiveRecord::Base
belongs_to :empresa
attr_accessor :senha1, :senha2
validates_presence_of :nome ,:message => "Preencha o campo
Nome"
validates_presence_of :senha1,:message => "Preencha o campo
Senha"
validates_presence_of :senha2,:message => "Preencha o campo
Confirmação de senha"
validates_presence_of :email, :message => "Preencha o campo
E-Mail"
validates_uniqueness_of :email, :message => "Este e-mail já esta
cadastrado"
(....)
model Empresa
--------------------------------------
class Empresa < ActiveRecord::Base
has_many :usuarios
validates_uniqueness_of :cnpj, :message => "Este CNPJ/CPF já esta
cadastrado"
validates_presence_of :cnpj, :message => "O campo CNPJ/CPF precisa ser
preenchido"
validates_presence_of :razao_social, :message => "O campo Razão Social
precisa ser preenchido"
end
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---