There are similar questions, but after 18h of reading them and several guides trying and trying I still haven't been able to solve my problem. That's why I'm posting this question. Thanks in advance!
Trying to POST data to create a new record but get "param is missing or the value is empty: todo"
FORM
<div class="addactionform">
<%= form_for(Action.new, :url => { action: "create" }) do |todo| %>
<div class="input-field"> <%= todo.text_field :title %> </div>
<div class="hidden"> <%= todo.submit %> </div>
<% end %>
</div>
ROUTE
root 'actions#inbox'
get '/actions' => 'actions#inbox'
post '/actions/create' => 'actions#create', as: :create
CONTROLLER
class ActionsController < ApplicationController
def inbox
@todos = Action.all
end
def new
@todo = Action.new
end
def create
@todo = Action.new(todo_params)
@todo.save
redirect_to(:action => 'inbox')
end
private
def todo_params
params.require(:todo).permit(:title)
end
end
ACTION MODEL
class Action < ActiveRecord::Base
has_many :tag, through: :action_tags
belongs_to :folder
belongs_to :user
belongs_to :state
end
MIGRATION
class CreateActions < ActiveRecord::Migration
def change
create_table :actions do |t|
t.string :title
t.text :note
t.references :tags
t.integer :assignee_id
t.references :state
t.datetime :due_at
t.integer :parent_id
t.references :folder
t.timestamps
end
end
end