i have a form which includes html tags for text field, such as <input type="text" name="text1"> rather than <%form.text_field :title %> i want to show error messages for these text fields when the user doesn''t fill the text field,but when i use html tag i couldn''t enter <%= error_messages_for "x" %> so how can i show error messages --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Ishara,
Look this snippet:
@model_object.errors.each do |attr, msg|
flash[:notice] << msg + "<br>"
end
Hope this helps you.
[ rui ]
[ Seiri, Seiton, Seisō, Seiketsu e Shitsuke ]
On Mon, Nov 3, 2008 at 8:31 AM, Ishara Gunathilake
<jaimgunathilake@gmail.com> wrote:> i have a form which includes html tags for text field,
> such as <input type="text" name="text1">
> rather than
> <%form.text_field :title %>
> i want to show error messages for these text fields
> when the user doesn't fill the text field,but when i use
> html tag i couldn't enter <%= error_messages_for "x" %>
> so how can i show error messages
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---
can u tell me at where should i place this code,,and what is the "errors" 2008/11/3 rui <ruivaldo@gmail.com>> Hi Ishara, > > Look this snippet: > > @model_object.errors.each do |attr, msg| > flash[:notice] << msg + "<br>" > end > > Hope this helps you. > > [ rui ] > [ Seiri, Seiton, Seisō, Seiketsu e Shitsuke ] > > > > On Mon, Nov 3, 2008 at 8:31 AM, Ishara Gunathilake > <jaimgunathilake@gmail.com> wrote: > > i have a form which includes html tags for text field, > > such as <input type="text" name="text1"> > > rather than > > <%form.text_field :title %> > > i want to show error messages for these text fields > > when the user doesn't fill the text field,but when i use > > html tag i couldn't enter <%= error_messages_for "x" %> > > so how can i show error messages > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---
A simple action as a sample:
Hi Ishara,
The method erros [
http://apidock.com/rails/ActiveModel/Validations/errors ] returns the
Errors objects of that model.
A simple example would be:
def my_action
@blog = Blog.new(params[:blog])
if @blog.save
flash[:notice] = "Blog saved"
else
@blog.errors.each do |attr, msg|
flash[:notice] << msg + "<br>"
end
end
redirect_to :back
end
[ rui ]
[ Seiri, Seiton, Seisō, Seiketsu e Shitsuke ]
2008/11/3 Ishara Gunathilake
<jaimgunathilake@gmail.com>:> can u tell me at where should i place this code,,and what is the
"errors"
>
> 2008/11/3 rui <ruivaldo@gmail.com>
>>
>> Hi Ishara,
>>
>> Look this snippet:
>>
>> @model_object.errors.each do |attr, msg|
>> flash[:notice] << msg + "<br>"
>> end
>>
>> Hope this helps you.
>>
>> [ rui ]
>> [ Seiri, Seiton, Seisō, Seiketsu e Shitsuke ]
>>
>>
>>
>> On Mon, Nov 3, 2008 at 8:31 AM, Ishara Gunathilake
>> <jaimgunathilake@gmail.com> wrote:
>> > i have a form which includes html tags for text field,
>> > such as <input type="text" name="text1">
>> > rather than
>> > <%form.text_field :title %>
>> > i want to show error messages for these text fields
>> > when the user doesn't fill the text field,but when i use
>> > html tag i couldn't enter <%= error_messages_for
"x" %>
>> > so how can i show error messages
>> >
>> > >
>> >
>>
>>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---