Forum: Ruby on Rails update_attributes and validation

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C47e75cdd405c006fb3a3a0cae147302?d=identicon&s=25 Nilesh Kulkarni (nilk_cse)
on 2009-03-13 13:00
hi all,


    I am updating 50 records on one page with update_attributes method
,my validations are


validates_numericality_of :year, :greater_than_or_equal_to => 1900,
:less_than_or_equal_to => 2028,  :message => "Year must be between 1900
and 2028"
valdate_presence_of:title
valdate_presence_of:price

id title           year        price
1  James bond      2008          $100
2  zoro the mask   1978          $ 50
.
.
.
.
50  don            2000         $400

if I provide wrong input for one say year "1800" for "don" and correct
for "james bond" year as "2000" it updates James bond ,correctly but do
not show validation message for "don" on my page. I want to display
message how can i do that
B6d7dffed1196ab1a2ac35504a0cb03c?d=identicon&s=25 Sumanth Krishna (sumi)
on 2009-03-13 13:45
(Received via mailing list)
try with update_attributes! (which internally uses 'save!')

On Fri, Mar 13, 2009 at 2:00 PM, Nilesh Kulkarni <
rails-mailing-list@andreas-s.net> wrote:

> and 2028"
> 50  don            2000         $400
>
> if I provide wrong input for one say year "1800" for "don" and correct
> for "james bond" year as "2000" it updates James bond ,correctly but do
> not show validation message for "don" on my page. I want to display
> message how can i do that
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>


--
--
Thanks & Regards,
Sumanth Krishna. A
+358 40 3276564

Blogs:
                        TwinclingCommunity:

http://sumanthtechsavvy.blogspot.com/
         http://www.twincling.org/node/227

http://yourway2health.blogspot.com/
           http://www.osef.twincling.org
C47e75cdd405c006fb3a3a0cae147302?d=identicon&s=25 Nilesh Kulkarni (nilk_cse)
on 2009-03-14 06:04
Sumanth Krishna wrote:
> try with update_attributes! (which internally uses 'save!')
>
> On Fri, Mar 13, 2009 at 2:00 PM, Nilesh Kulkarni <
> rails-mailing-list@andreas-s.net> wrote:
>
>> and 2028"
>> 50  don            2000         $400
>>
>> if I provide wrong input for one say year "1800" for "don" and correct
>> for "james bond" year as "2000" it updates James bond ,correctly but do
>> not show validation message for "don" on my page. I want to display
>> message how can i do that
>> --
>> Posted via http://www.ruby-forum.com/.
>>
>> >
>>
>
>
> --
> --
> Thanks & Regards,
> Sumanth Krishna. A
> +358 40 3276564
>
> Blogs:
>                         TwinclingCommunity:
>
> http://sumanthtechsavvy.blogspot.com/
>          http://www.twincling.org/node/227
>
> http://yourway2health.blogspot.com/
>            http://www.osef.twincling.org
hi

I have used update_attributes! it shows validation message

ActiveRecord::RecordInvalid in BookController#edit_book

Validation failed: Year should be a above 1900

on different page ,but i want that message must be displayed on same
page on top
my controller look like this

def edit_book
 if request.post?
  # code for update data ie "update_attribute!" method
end
   @books = Book.find(:all)
end

and I have view named "edit_book.html.erb"
This topic is locked and can not be replied to.