를 작동하지 않는 것은 여기 update_attributes가
<h1>WEEKLY EXERCICES</h1>
Day : <%= @dayly_activity.day %>
<%= form_for(@dayly_activity, :url => { :action => "updatexercises" }) do | f | %>
<table>
<tr>
<td>Jogging:</td>
<td>
<% list = (0..20).to_a %>
<%= f.select :jog, list %>
x 0.1 km
</td>
</tr>
<tr>
<td>Bicycling:</td>
<td>
<% list = (0..10).to_a %>
<%= f.select :bicycl, list %>
km
</td>
</tr>
<tr>
<td>Push ups:</td>
<td>
<% list = (0..20).to_a %>
<%= f.select :pushups, list %>
x 10 times
</td>
</tr>
<tr>
<td colspan = "2"><%= f.submit %></td>
</tr>
</table>
<% end %>
내가 버튼을 클릭
데일리 + 활동 객체가 저장되지 않는 내 컨트롤러class ActivitiesController < ApplicationController
def exercises
if current_user.userprofile.present? #chef whether there is a userprofile object
@weeknum = current_user.userprofile.week
@dayly_activity = Activity.where(:week => 1, :day => 'Monday').first
end #end check userprofile
end
def updatexercises
respond_to do | format |
@dayly_activity = Activity.where(:week => 1, :day => 'Monday').first
@dayly_activity.update_attributes(params[:@dayly_activity])
@dayly_activity.save
format.html { render action: "exercises" }
end
end
end
그리고 내 템플릿입니다. 내가 어떤 일을 놓치고
편집
내가 하드 코딩이 방법을 시도하고는 데이터베이스에 저장.
@dayly_activity.jog = 17
@dayly_activity.pushups = 13
@dayly_activity.save
분명히, 문제는 update_attributes 당신은 params[:dayly_activity]
를 사용 (@ 기호를 삭제) 할 필요가
'의 PARAMS [: dayly_activity @]''제거는 @' – ck3g
는 유일한 문제인가요? @ 기호를 제거했습니다. 아직 저장하지 않습니다. – Richard77