0
안녕하세요, 사용자가 특정 링크를 클릭하면 내 데이터베이스 (PostgreSQL) 내에서 값을 업데이 트하려고 노력하고 있는데, 나는 최선의 방법이라고 생각하지 않습니다. 사람이 내가 더 잘 달성 할 수있는 방법을 보여줄 수 있다면이클릭하면 데이터베이스를 업데이트하십시오.
보기
%ul.button-group.round.even-3
%li= link_to '<i class="general foundicon-checkmark"></i>'.html_safe, accept_availability_path(a), :method => 'put', :remote => true, :class => 'button success tiny', :id => a.id, :disable_with => ''
컨트롤러
def accept
@availability = Availability.find(params[:id])
@availability.available= true
respond_to do |format|
if @availability.update_attributes(params[:availability])
format.html { render :nothing => true }
format.js
else
format.html { render :action => "edit" }
format.js
end
end
end
루트
resources :availabilities do
put 'accept', :on => :member
put 'decline', :on => :member
end
가? –
그들은 절대적으로 좋아 보입니다. 귀하의 경로가 간소화되고 답변이 업데이트 될 수 있습니다. 당신의 링크는 괜찮습니다.'link_to_remote'는 이것을하기위한 방법 이었지만 레일 3에서는': remote => true'를 사용하지 않을 것입니다. – Matt
하지만 내 링크에': method => 'put ''을 사용해야합니다. –