This is my form:
===========================
<% form_tag :action => 'update', :id => @book.id, :title => @book.title,
:price => @book.price, :description => @book.description %>
<%= render :partial => 'form' %>
<%= submit_tag 'Edit' %>
<% end %>
===========================
This is my controller code
===========================
def update
@book = Book.find(params[:id])
@book.update_attribute(:title, params[:title])
@book.update_attribute(:description, params[:description])
@book.update_attribute(:price, params[:price])
if @book.update_attributes(params[:book])
flash[:notice] = 'Book was successfully updated.'
redirect_to :action => 'show', :id => @book
else
render :action => 'edit'
end
end
=============================
I am trying to update only selected fields as shown in the database. Seems CRUD cant allow me. I am getting errors. How do I pass values from form fields to be used by the " @book.update_attribute". to update database fields; How can I update only selected using this method
fields in the database.
I ve struggled for a 2 weeks now. How do I go round it