我是Ruby on Rails的新手,即時通訊練習使用它..我創建了一個使用rails generate controller activity list add edit delete
和rails generate model activity name:string summary:text
的應用程序,並且運行良好..在我的RoR應用程序的表中添加了一個新列,但無法添加詳細信息
但是,當我使用sqlite3的添加一列到表NEWAPP並嘗試添加新記錄.. everyhting工作正常..沒有錯誤,但迄今未保存..爲什麼會出現這種情況?我認爲這可能是一個非常小的問題,但即時通訊,已有3小時變薄的工作,可能沒有意識到這一點..任何幫助表示讚賞
這是我的控制器的代碼
def create
@activity_detail = Activity.new(activity_detail_params)
respond_to do |format|
if @activity_detail.save
format.html { redirect_to activity_new_path, notice: 'Activity details were successfully saved.' }
format.json { render :view, status: :created, location: @activity_detail }
else
format.html { render :new }
format.json { render json: @activity_detail.errors, status: :unprocessable_entity }
end
end
end
def activity_detail_params params.require(:activity).permit(:name, :summary, :dated) end
(我說:我的日期表的修改後)
我看來碼
<%= form_for :activity, url: activity_create_url do |f| %>
<div class="field">
<%= f.label :name %> * <%= f.text_field :name , class: "text" %>
</div>
<span id="title-err"></span>
<div class="field">
<%= f.label :date %> * <%= f.text_field :dated , class: "text" %>
</div><span id="date-err"></span>
<div class="field">
<%= f.label :summary %> <%= f.text_area :summary , class: "text" %>
</div>
<div class="actions">
<%= link_to 'Cancel', activity_view_path, class:"link" %> <%= f.submit %>
</div>
<% end %>
服務器日誌
Started GET "/assets/jquery-ui/ui-bg_glass_75_dadada_1x400.png" for 127.0.0.1 at
2014-07-24 16:34:34 +0530
Started POST "/activity/create" for 127.0.0.1 at 2014-07-24 16:34:42
+0530 Processing by ActivityController#create as HTML Parameters: {"utf8"=>"√", "authenticity_token"=>"1WrRLrAEdga7IiZzf11hec2dv/yzs
+Qq//Q3U9B9urw=", "activity"=>{"name"=>"new", "dated"=>"07/23/2014", "summary"=> "asf"}, "commit"=>"Save Activity"} Unpermitted parameters:
dated (0.0ms) begin transaction SQL (0.0ms) INSERT INTO
"activities" ("created_at", "name", "summary", "updat ed_at") VALUES
(?, ?, ?, ?) [["created_at", "2014-07-24 11:04:42.671875"], ["na me",
"new"], ["summary", "asf"], ["updated_at", "2014-07-24
11:04:42.671875"]] (156.3ms)
在此先感謝
顯示一些代碼。 –
好的..我已經添加了代碼給我的問題.. – ss56
你可以發佈你的'查看代碼'嗎? – Pavan