make sm_controller show the error in the js

This commit is contained in:
maxwell 2011-02-22 22:21:48 -08:00
parent 5bce2d1615
commit e446dcaeb5
2 changed files with 9 additions and 4 deletions

View file

@ -18,7 +18,7 @@ class StatusMessagesController < ApplicationController
public_flag.to_s.match(/(true)|(on)/) ? public_flag = true : public_flag = false
params[:status_message][:public] = public_flag
@status_message = current_user.build_post(:status_message, params[:status_message])
@status_message = current_user.build_post(:status_message, params[:status_message].merge!(:message => ''))
aspects = current_user.aspects_from_ids(params[:aspect_ids])
if @status_message.save
@ -59,7 +59,7 @@ class StatusMessagesController < ApplicationController
end
else
respond_to do |format|
format.js { render :text => @status_message.errors.full_messages, :status => 406 }
format.js { render :json =>{:errors => @status_message.errors.full_messages}, :status => 406 }
format.html {redirect_to :back}
end
end

View file

@ -60,7 +60,12 @@ var Stream = {
});
$(".new_status_message").bind('ajax:failure', function(data, html , xhr) {
json = $.parseJSON(html.response);
if(json.errors.length != 0){
Diaspora.widgets.alert.alert(json.errors);
}else{
Diaspora.widgets.alert.alert('Failed to post message!');
}
});
$(".new_comment").live('ajax:success', function(data, json, xhr) {