我有实现模型:
# encoding : utf-8
class Realization < ActiveRecord::Base
attr_accessible :city, :street, :title, :work, :photo, :date
has_attached_file :photo
end
控制器:
# encoding : utf-8
class RealizationsController < ApplicationController
before_filter :admin_required, :except => [:index,:show]
# GET /realization/new
def new
@realization = Realization.new
@realization.date = Time.now.__send__(:to_date).to_s
end
# POST /realization
def create
@realization = Realization.new(params[:realization])
if @realization.save
redirect_to @realization, notice: 'realization was successfully created.'
else
render action: "new"
end
end
(...) others
表格视图:
<%= form_for @realization, :html => { :multipart => true } do |f| %>
<% if @realization.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@realization.errors.count, "error") %> prohibited this realization from being saved:</h2>
<ul>
<% @realization.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :title %><br />
<%= f.text_field :title %>
</div>
(...)
<div class="field">
<%= f.file_field :photo %>
</div>
<div class="actions">
<%= f.submit "Submit" %>
</div>
<% end %>
和路线:
resources :realizations
而WEBrick服务器信息是:
Started POST "/realizacje" for 127.0.0.1 at 2013-04-12 12:26:35 +0200
Processing by RealizationsController#index as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"zK5jP4ChBBY+R21TjrZkp4xGvCHViTFJ+8Fw6Og28YY=", "realization"=>{"title"=>"wwwwww", "street"=>"", "city"=>"", "work"=>"", "date"=>"2013-04-12"}, "commit"=>"Submit"}
(1.0ms) SELECT COUNT(*) FROM "realizations"
Realization Load (2.0ms) SELECT "realizations".* FROM "realizations" ORDER BY created_at DESC LIMIT 7 OFFSET 0
User Load (1.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Rendered realizations/index.html.erb within layouts/application (156.0ms)
Completed 200 OK in 340ms (Views: 333.0ms | ActiveRecord: 4.0ms)
当我使用表单并推送提交时,它重定向/randers 实现/索引,甚至没有通知或错误!我完全不知道为什么?特别是它以前工作过......也许后来添加的javascript可能是原因?回形针在更新中运行良好,所以不是......