Rails不保存新记录

时间:2019-04-25 21:12:34

标签: ruby-on-rails

我的Rails应用程序不保存记录,而仅保存一种模型

这是我的创建控制器:

def create
  @tuning = Tuning.new(tuning_params)

  respond_to do |format|
    if @tuning.save
      format.html { redirect_to @tuning, notice: 'Tuning was successfully added.' }
      format.json { render :show, status: :created, location: @tuning }
    else
      format.html { render :new }
      format.json { render json: @tuning.errors, status: :unprocessable_entity }
    end
  end

  add_breadcrumb "Up-coming tunings", :root_path
end

这是我的表格:

<%= simple_form_for @tuning do |f| %>
  <div class="row">   
    <div class="form-inputs col-md-6">
      <%= f.check_box :archive %> Archive?<br><br>
      <%= f.input :Client %>
      <%= f.input :Tel %>
      <%= f.datetime_select :scheduled_date %>
      <%= f.input :email %>
      <%= f.input :Address, as: :text %>
      <%= f.input :city %>
      <%= f.input :Quote %>
    </div>
    <div class="col-md-6">
      <%= f.input :Type, as: :select, collection: [['Baby Grand', 'Baby Grand'], ['Grand', 'Grand'], ['Concert Grand', 'Concert Grand'], ['Upright', 'Upright'], ['Console', 'Console'], ['Spinet', 'Spinet']], label_method: :second, value_method: :first %>
      <%= f.input :Make %>
      <%= f.input :Model %>
      <%= f.input :Sn %>
      <%= f.input :Work_needed, as: :text %>
      <%= f.input :Comments %>
      <%= f.input :youtube_video %>
      <%= f.input :source, as: :select, collection: [['Thumbstack', 'Thumbstack'], ['Website', 'Website'], ['Google', 'Google'], ['Yelp', 'Yelp'], ['Recommendation', 'Recommendation'], ['Teacher', 'Teacher'], ['Houston Piano Company', 'Houston Piano Company'], ['Other', 'Other']], label_method: :second, value_method: :first %>
      <%= f.button :submit %>
      <%= link_to ' Destroy', tuning, method: :delete, data: { confirm: 'Are you sure?' }, :class =>'btn glyphicon glyphicon-trash' %>
    </div>
  </div>
<% end %>

有趣的是,这只是几天前才开始令人发笑,我无法解决

在此先感谢您的帮助,我需要运行该程序来保存新的钢琴调音客户。并保持我的头上。

服务器日志:

 Started GET "/tunings/new?utf8=%E2%9C%93&authenticity_token=tF03oN3LNBv4ubAuPH5xplmKx9yq0yiWFhk0PXdpi%2F0h9G2YpigHQCBBXq1XEGERbzBNii3%2BOX5a2qWbkwnoSw%3D%3D&utf8=%E2%9C%93&authenticity_token=%2F8JpV%2BUVxdvIIUJ3djm5QgpdCHuHa1V9B0XyPC176SlqazNvnvb2gBDZrPQdV6n1POeCLQBGRJVLhmOayRuKnw%3D%3D&tuning%5Barchive%5D=0&tuning%5BClient%5D=Test&tuning%5BTel%5D=Test&tuning%5Bscheduled_date%281i%29%5D=2019&tuning%5Bscheduled_date%282i%29%5D=4&tuning%5Bscheduled_date%283i%29%5D=26&tuning%5Bscheduled_date%284i%29%5D=00&tuning%5Bscheduled_date%285i%29%5D=15&tuning%5Bemail%5D=&tuning%5BAddress%5D=Test&tuning%5Bcity%5D=&tuning%5BQuote%5D=&tuning%5BType%5D=&tuning%5BMake%5D=&tuning%5BModel%5D=&tuning%5BSn%5D=&tuning%5BWork_needed%5D=&tuning%5BComments%5D=&tuning%5Byoutube_video%5D=&tuning%5Bsource%5D=&commit=Create+Tuning" for 127.0.0.1 at 2019-04-25 19:15:32 -0500
Processing by TuningsController#new as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"/8JpV+UVxdvIIUJ3djm5QgpdCHuHa1V9B0XyPC176SlqazNvnvb2gBDZrPQdV6n1POeCLQBGRJVLhmOayRuKnw==", "tuning"=>{"archive"=>"0", "Client"=>"Test", "Tel"=>"Test", "scheduled_date(1i)"=>"2019", "scheduled_date(2i)"=>"4", "scheduled_date(3i)"=>"26", "scheduled_date(4i)"=>"00", "scheduled_date(5i)"=>"15", "email"=>"", "Address"=>"Test", "city"=>"", "Quote"=>"", "Type"=>"", "Make"=>"", "Model"=>"", "Sn"=>"", "Work_needed"=>"", "Comments"=>"", "youtube_video"=>"", "source"=>""}, "commit"=>"Create Tuning"}
  Rendering tunings/new.html.erb within layouts/application
  Rendered tunings/_form.html.erb (47.5ms)
   (0.4ms)  SELECT COUNT(*) AS count_all, strftime('%Y-%m-01 00:00:00 UTC', scheduled_date) AS strftime_y_m_01_00_00_00_utc_scheduled_date FROM "tunings" WHERE (scheduled_date IS NOT NULL) GROUP BY strftime('%Y-%m-01 00:00:00 UTC', scheduled_date)
  ↳ /Users/EvanRoberts/.rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.2.0/lib/active_support/subscriber.rb:101
  Rendered tunings/new.html.erb within layouts/application (60.6ms)
   (0.2ms)  SELECT COUNT(*) FROM "tunings" WHERE (scheduled_date >= '2019-04-25')
  ↳ /Users/EvanRoberts/.rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.2.0/lib/active_support/subscriber.rb:101
   (0.1ms)  SELECT COUNT(*) FROM "tunings" WHERE (scheduled_date < '2018-10-26 00:15:32.330442')
  ↳ /Users/EvanRoberts/.rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.2.0/lib/active_support/subscriber.rb:101
   (0.2ms)  SELECT COUNT(*) FROM "tunings" WHERE (scheduled_date < '2018-04-26 00:15:32.331271')
  ↳ /Users/EvanRoberts/.rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.2.0/lib/active_support/subscriber.rb:101
Completed 200 OK in 119ms (Views: 110.7ms | ActiveRecord: 0.9ms)

0 个答案:

没有答案