2011-08-31 2 views
1

질문의 나쁜 표현에 사과드립니다.jquery에서 레일에 이르는 게시물에 응답

나는 레일 앱이 PARAMS을 받으면, 나는에 전달 된 텍스트로 다시 응답하고 싶습니다 같은

$(document).ready(function() { 
    console.log("[email protected]£"); 
    $('.editable-td').editable(home_address, { 
     data : " {'E':'Letter E','F':'Letter F','G':'Letter G', 'selected':'F'}", 
     type  : 'textarea', 
     cancel : 'Cancel', 
     submit : 'OK', 
     tooltip : 'Click to edit...' 
    }); 
}); 

로 레일 응용 프로그램을 통해 일부 PARAMATERS을 보내고있다. 그렇지 않으면 후에 레일 서버에 데이터를 제출하면 업데이트 한 텍스트 영역이 이전 상태로 되돌아갑니다.

def update 
    puts params 

    puts "NOWWHATSHOULDIDO" 

    respond_to :json 
    if params 
     respond_with(params) do |format| 
     format.json { render } 
     end 
    end 
    end 

작은 또 다른 시도이다 둔다 "NOWWHATSHOULDIDO"

respond_to do |format| 
     if params 
     format.json { head :ok } 
#   respond with the variable @response here 
     else 
     format.json { render :json => @user.errors, :status => :unprocessable_entity } 
     end 
    end 
    end 

작은 시도 :

DEF 둔다의 PARAMS @response = ([값] PARAMS)를 업데이트 여기서 사용자에게 응답하지만 jeditable 영역은 null로 표시됩니다. 어떤 아이디어?

(가) 먼저 수를 들어
def update 
    puts params 
    @x = (params[:values]) 
    render :json => @x.to_json 
    end 

답변

0

, 당신이 할 수있는 생각 :

render :text => params[:value], :status => :ok