Hi,
I have edit page for a model, where edit button is given as
submit_to_remote, where i specify in which div the content should be
updated, but if validation fails, like if while editing, mandatory field
is left empty, i need to update the error in some other div. how is it
possible.
#controller
def create
@question = Question.new(params[:question])
if @question.save
@questions = Question.find(:all, :conditions => {:subject_id =>
@question.subject_id })
#render :text => "saved"
render :partial => "display_all"
#redirect_to :action => 'display_all', :subj_id =>
@question.subject_id
else
@question.errors.each_full do |msg|
if @error != nil
@error.concat(msg)
else
@error = msg;
end
end
render :text => @error
end
end
This is called from view as
<%= submit_to_remote 'create', 'Create', :url => {:action => 'create'},
:update => 'questions' %>
I need to update errors in another div say error, that will appear at
the top of the page. how is it possible? can we do with render :update
do |page| ? but it is showing me error
--
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 [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
-~----------~----~----~----~------~----~------~--~---