Created
December 22, 2016 14:47
-
-
Save malgorath/cf8ba2657bba45035df2fa215125bd9b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ArgumentError in MasterLists#create | |
Showing /Projects/rails_projects/ProcessSteps/app/views/master_lists/_form.html.erb where line #1 raised: | |
First argument in form cannot contain nil or be empty | |
Extracted source (around line #1): | |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
<%= form_for(master_list) do |f| %> | |
<% if master_list.errors.any? %> | |
<div id="error_explanation"> | |
<h2><%= pluralize(master_list.errors.count, "error") %> prohibited this master_list from being saved:</h2> | |
<ul> | |
Trace of template inclusion: app/views/master_lists/new.html.erb | |
Rails.root: /Projects/rails_projects/ProcessSteps | |
Application Trace | Framework Trace | Full Trace | |
app/views/master_lists/_form.html.erb:1:in `_app_views_master_lists__form_html_erb___887718772740080326_69888290694480' | |
app/views/master_lists/new.html.erb:3:in `_app_views_master_lists_new_html_erb__2646737281241535987_69888290846520' | |
app/controllers/master_lists_controller.rb:43:in `create' | |
Request | |
Parameters: | |
{"utf8"=>"✓", | |
"authenticity_token"=>"tIVEHUmzaBQ1cV13BPp1T4JKg1jqvTuOvmi/zNyg4F1wlTfOhwoAlviYxvqyD6FEcDlUqqMogBsFBuKlWrVkSA==", | |
"master_list"=>{"title"=>"Test 1", "description"=>"Test 1", "deleted"=>"0"}, | |
"commit"=>"Create Master list"} | |
Toggle session dump | |
Toggle env dump | |
Response | |
Headers: | |
None | |
x | |
>> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_support' | |
class MasterListsController < ApplicationController | |
before_action :set_master_list, only: [:show, :edit, :update, :destroy] | |
# GET /master_lists | |
# GET /master_lists.json | |
def index | |
@master_lists = MasterList.all | |
end | |
# GET /master_lists/1 | |
# GET /master_lists/1.json | |
def show | |
end | |
# GET /master_lists/new | |
def new | |
@master_list = MasterList.new | |
end | |
# GET /master_lists/1/edit | |
def edit | |
end | |
# POST /master_lists | |
# POST /master_lists.json | |
def create | |
entry = MasterList.find_by 'title', master_list_params[:title] | |
if entry | |
@master_list = MasterList.new(master_list_params) | |
respond_to do |format| | |
if @master_list.save | |
format.html { redirect_to @master_list, notice: 'Master list was successfully created.' } | |
format.json { render :show, status: :created, location: @master_list } | |
else | |
format.html { render :new } | |
format.json { render json: @master_list.errors, status: :unprocessable_entity } | |
end | |
end | |
else | |
flash[:notice] = 'Title must be unique' | |
render :new | |
end | |
end | |
# PATCH/PUT /master_lists/1 | |
# PATCH/PUT /master_lists/1.json | |
def update | |
respond_to do |format| | |
if @master_list.update(master_list_params) | |
format.html { redirect_to @master_list, notice: 'Master list was successfully updated.' } | |
format.json { render :show, status: :ok, location: @master_list } | |
else | |
format.html { render :edit } | |
format.json { render json: @master_list.errors, status: :unprocessable_entity } | |
end | |
end | |
end | |
# DELETE /master_lists/1 | |
# DELETE /master_lists/1.json | |
def destroy | |
@master_list.destroy | |
respond_to do |format| | |
format.html { redirect_to master_lists_url, notice: 'Master list was successfully destroyed.' } | |
format.json { head :no_content } | |
end | |
end | |
private | |
# Use callbacks to share common setup or constraints between actions. | |
def set_master_list | |
@master_list = MasterList.find(params[:id]) | |
end | |
# Never trust parameters from the scary internet, only allow the white list through. | |
def master_list_params | |
params.require(:master_list).permit(:title, :description, :deleted) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment