I'm completely at a loss! I'm using decent_exposure gem for a first time and I suppose the problem is in it. That's the link https://github.com/hashrocket/decent_exposure When I submit my form, it saves nothing. All my table in database are just full of empty fields. This is my form
<%= simple_form_for book do |f| %>
<%= f.input :name %>
<%= f.input :author %>
<%= f.input_field :annotation %>
<%= f.button :submit %>
<% end %>
This is my controller:
class BooksController < ApplicationController
before_filter :is_admin?
before_filter :authenticate_user!
expose(:book, finder_parameter: :id, params: :book_params)
#I've tried both expose(:book) and expose(:books)
def create
if book.save
redirect_to(book)
else
render :new
end
end
def update
if book.save
redirect_to(book)
else
render :edit
end
end
def show
end
def is_admin?
if current_user.admin?
true
else
render :text => 'Registrate'
end
end
def book_params
params.require(:book).permit(:name, :author, :annotation)
end
end
It gives a mistake
param is missing or the value is empty: book
def book_params params.require(:book).permit(:name, :author, :anotation) end
If I try just expose(:book) without params and book_params method, it seems to be okay but after submitting the form all the fields are nil. What am I doing wrong? Is there any mistake in params defining? I've been thinking and trying different variants for many many times and I can't imagine where is the problem. Every help would be appreciated!
I found it! There was "attribures: :book_params" instead of "params: :book_params"