Rails ActionController::UnpermittedParameters found unpermitted parameter when param present - ruby-on-rails

I have the following form that is trying to load in checkboxes with labels all regions and allow those to be saved to logos on the Logo form page.
= tb_form_for [:admin, #logo],
remote: true,
data: { errors: :inline, success: admin_logos_path } do |f|
= tb_form_errors(f.object, :base)
= f.tb_text_field :name
= f.tb_check_box :home_page, class: 'checkmark'
= f.tb_file_field :logo_photo
= image_tag #logo.logo_photo, style: 'padding-left: 180px; padding-bottom: 20px;' if #logo.logo_photo.present?
= f.collection_check_boxes :region_id, Region.all, :id, :name, checked: Region.all.map(&:id) do |x|
div
= x.check_box
= x.label
= f.tb_save_buttons('Logo', admin_logos_path)
The page loads properly but the error cames with saving I end up with
ActionController::UnpermittedParameters (found unpermitted parameter: :region_id)
Cool so I check my LogosController and I have the following:
class LogosController < ApplicationController
before_action :load_logo, only: [:show, :edit, :update, :destroy]
def create
#logo = Logo.new(logo_params)
flash[:notice] = 'Created' if #logo.save
respond_with #logo
end
def edit
respond_with #logo
end
def update
flash[:notice] = 'Updated' if #logo.update_attributes(logo_params)
respond_with #logo
end
private
def logo_params
params.require(:logo).permit(:name, :home_page, :user, :region, :logo_photo, :region_id, :user_id)
end
end
I've tried several variations on the first argument being passed:
#logo.region results in
found unpermitted parameter: :Region::ActiveRecord_Associations_CollectionProxy:0x00007f81a79a81e0>
:region results in
found unpermitted parameter: :region
#logo results in
found unpermitted parameter: :Logo:0x00007f81a34da8
#logo.region_id ends up with a Bad Request
expected Array (got Rack::QueryParser::Params) for param `logo'
How do I accurately hit this?
Edit:
From the log:
Parameters: {"id"=>"12"}
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
(0.2ms) BEGIN
SQL (0.5ms) UPDATE "users" SET "perishable_token" = $1, "last_request_at" = $2, "updated_at" = $3 WHERE "spud_users"."id" = $4 [["perishable_token", "aFl2KBnsphPP4I6CwXO2"], ["last_request_at", "2018-08-31 15:48:15.999796"], ["updated_at", "2018-08-31 15:48:16.000920"], ["id", 1]]
(5.4ms) COMMIT
Logo Load (0.5ms) SELECT "logos".* FROM "logos" WHERE "logos"."id" = $1 LIMIT $2 [["id", 12], ["LIMIT", 1]]
Rendering admin/logos/edit.html.slim within layouts/admin/detail
Region Load (0.5ms) SELECT "regions".* FROM "regions"
CACHE Region Load (0.0ms) SELECT "regions".* FROM "regions"
Rendered admin/logos/_form.html.slim (111.2ms)
Log when submitting the form:
Started PATCH "/admin/logos/12" for 127.0.0.1 at 2018-09-04 09:02:43 -0400
Processing by Admin::LogosController#update as JSON
Parameters: {"utf8"=>"✓", "logo"=>{"name"=>"Mr-T", "home_page"=>"1", "region_id"=>["", "1", "3", "4", "2"]}, "commit"=>"Save Logo", "id"=>"12"}
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
Logo Load (0.2ms) SELECT "logos".* FROM "logos" WHERE "logos"."id" = $1 LIMIT $2 [["id", 12], ["LIMIT", 1]]
Completed 500 Internal Server Error in 4ms (ActiveRecord: 0.5ms)
ActionController::UnpermittedParameters (found unpermitted parameter: :region_id):
app/controllers/admin/logos_controller.rb:48:in `logo_params'
app/controllers/admin/logos_controller.rb:32:in `update'

Change ":region" by ":region_id" on "logo_params" like this
params.require(:logo).permit(:name, :home_page, :user, :region_id, :logo_photo,:user_id)

Related

Ajax in Rails 5 throw "ActionController::UnknownFormat " error

I am trying to implement a search method that will automaticaly populate a form through the use of Ajax.
I have a simple_form_form that is feed with a collection of Client instance. Once I select a client, a js code submit the form and then goes to the corresponded controller method.
This part is working, but when the code hits the Client#search it stops at my "respond_to |format|" line. Stating that this is an unknown format.
I looked differents stackover posts, but I could'nt find any concrete answers.
Thanks,
here is the code:
My error:
error messages
routes.rb
Rails.application.routes.draw do
class OnlyAjaxRequest
def matches?(request)
request.xhr?
# raise
end
end
get 'search', to: 'invoices#search', as: 'search', constraint: OnlyAjaxRequest.new
end
formSubmit.js
let clientOption = document.querySelector('#search_client');
const form = document.querySelector('.search');
clientOption.addEventListener('change', (event) => {
form.submit();
})
Client Controller:
def search
if params[:search]
#client_found = Client.find(params[:search][:client]) if Client.find(params[:search][:client]).present?
respond_to do |format|
#format.html {}
format.js { render :search}
end
end
end
Search.js.erb
console.log('hello');
$('#ajx-cli').html("<%= escape_javascript(render partial: 'invoices/invoice_new_partial/find_client')%>");
Client Selection Form
<%= simple_form_for :search, url: search_path, remote: true, method: :get, html: { id: :find_cli } do |f| %>
<%= f.input :client, label:"Sélectionnez un client", collection: #my_clients, label_method: :company_name, value_method: :id, include_blank: true, as: :select %>
<% end %>
Updated Form
<div id='ajx-cli'>
<%= f.fields_for :client do |client| %>
<%= render partial: "invoices/invoice_new_partial/oneoff_client",locals: {f: client, client_found: #client_found} %>
<% end %>
</div>
Also, my search action seems to be processed as html instead of js.
Logs terminal
Started GET "/search?utf8=%E2%9C%93&search%5Bclient%5D=176" for ::1 at 2020-10-17 14:15:07 +0200
Processing by InvoicesController#search as HTML
Parameters: {"utf8"=>"✓", "search"=>{"client"=>"176"}}
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 92], ["LIMIT", 1]]
↳ /Users/utilisateur/.rvm/gems/ruby-2.6.3/gems/activerecord-5.2.3/lib/active_record/log_subscriber.rb:98
Invoice Exists (0.7ms) SELECT 1 AS one FROM "invoices" WHERE (due_date < '2020-10-17') AND "invoices"."status" != $1 LIMIT $2 [["status", 3], ["LIMIT", 1]]
↳ app/controllers/application_controller.rb:32
Invoice Update All (0.9ms) UPDATE "invoices" SET "status" = 4 WHERE (due_date < '2020-10-17') AND "invoices"."status" != $1 [["status", 3]]
↳ app/controllers/application_controller.rb:34
Client Load (0.2ms) SELECT "clients".* FROM "clients" WHERE "clients"."id" = $1 LIMIT $2 [["id", 176], ["LIMIT", 1]]
↳ app/controllers/invoices_controller.rb:56
CACHE Client Load (0.0ms) SELECT "clients".* FROM "clients" WHERE "clients"."id" = $1 LIMIT $2 [["id", 176], ["LIMIT", 1]]
↳ app/controllers/invoices_controller.rb:56
Completed 406 Not Acceptable in 9ms (ActiveRecord: 2.3ms)
ActionController::UnknownFormat (ActionController::UnknownFormat):
app/controllers/invoices_controller.rb:58:in `search'
EDIT
Trying to force format didn't work either. My request was correctly processed as JS, so I didn't have the same error, but my search.js.erb was rendered instead of being executed.
New Invoice#search
def search
if params[:search]
#client_found = Client.find(params[:search][:client]) if Client.find(params[:search][:client]).present?
respond_to do |format|
format.js { render layout: false, content_type: 'text/javascript'}
end
end
New Client Selection Form
<%= simple_form_for :search, url: search_path(format: :js), remote: true, method: :get, html: { id: :find_cli } do |f| %>
<%= render partial: "invoices/invoice_new_partial/client_selection",locals: {my_clients: #my_clients, f: f, client_found: #client_found} %>
<% end %>
Logs:
Started GET "/search.js?utf8=%E2%9C%93&search%5Bclient%5D=178" for ::1 at 2020-10-17 19:19:43 +0200
Processing by InvoicesController#search as JS
Parameters: {"utf8"=>"✓", "search"=>{"client"=>"178"}}
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 92], ["LIMIT", 1]]
↳ /Users/utilisateur/.rvm/gems/ruby-2.6.3/gems/activerecord-5.2.3/lib/active_record/log_subscriber.rb:98
Invoice Exists (0.6ms) SELECT 1 AS one FROM "invoices" WHERE (due_date < '2020-10-17') AND "invoices"."status" != $1 LIMIT $2 [["status", 3], ["LIMIT", 1]]
↳ app/controllers/application_controller.rb:32
Invoice Update All (6.5ms) UPDATE "invoices" SET "status" = 4 WHERE (due_date < '2020-10-17') AND "invoices"."status" != $1 [["status", 3]]
↳ app/controllers/application_controller.rb:34
Client Load (0.3ms) SELECT "clients".* FROM "clients" WHERE "clients"."id" = $1 LIMIT $2 [["id", 178], ["LIMIT", 1]]
↳ app/controllers/invoices_controller.rb:56
CACHE Client Load (0.1ms) SELECT "clients".* FROM "clients" WHERE "clients"."id" = $1 LIMIT $2 [["id", 178], ["LIMIT", 1]]
↳ app/controllers/invoices_controller.rb:56
Rendering invoices/search.js.erb
Rendered invoices/invoice_new_partial/_find_client.html.erb (0.5ms)
Rendered invoices/search.js.erb (2.2ms)
Completed 200 OK in 24ms (Views: 5.6ms | ActiveRecord: 7.9ms)
I couldn't wrapped my mind around why my js.erb was rendered as a plain text, instead of being executed, so I started over.
I updated my form Submit.js and it worked like a charm.
New routes.rb
post 'search', to: 'invoices#search', as: 'search'
New Client Selection form
<%= simple_form_for :search, remote: true, html: { id: :find_cli } do |f| %>
<%= render partial: "invoices/invoice_new_partial/client_selection",locals: {my_clients: #my_clients, f: f, client_found: #client_found} %>
<% end %>
New formSubmit.js
let clientOption = document.querySelector('#search_client');
const form = document.querySelector('.search');
clientOption.addEventListener('change', (event) => {
let selector = document.querySelector('#search_client')
let client = selector.options[selector.selectedIndex].value;
Rails.ajax({
type: "post",
url: `/search?utf8=✓&search%5Bclient%5D=${client}`,
headers: {
accept: '*/*',
'X-CSRF-Token': Rails.csrfToken()
}
});
});

user.update rollback error in model method

As everything working as expected, i'm trying to save the new values in the database but i'm getting a rollback error on update
my model.rb
class User < ApplicationRecord
before_update :update_password
def self.update_password(username, new_password, new_password_conf, old_password)
user = find_by_username(username)
if new_password == new_password_conf && BCrypt::Engine.hash_secret(old_password, user.salt) == user.encrypted_password
new_salt = BCrypt::Engine.generate_salt
new_pass = BCrypt::Engine.hash_secret(new_password, new_salt)
user.update(encrypted_password: new_pass, salt: new_salt)
else
puts "Something went Wrong"
end
end
end
my users_controller.rb
def change_password
user = User.update_password( User.find(session[:user_id]).username,params[:password],params[:password_confirmation],params[:old_password])
end
my html.erb
<%= form_for(:user, :url => {:controller => 'users', :action => 'change_password'}) do |f| %>
<center><p> Παλιός Κωδικός Πρόσβασης</br> <%= f.password_field :old_password, placeholder: "Παλιός Κωδικός Πρόσβασης", name: "old_password"%> </p></center>
<center><p> Νέος Κωδικός Πρόσβασης</br> <%= f.password_field :password, placeholder: "Νέος Κωδικός Πρόσβασης", name: "password"%></p></center>
<center><p> Επιβεβαίωση Νέου Κ.Πρόσβασης</br> <%= f.password_field :password_confirmation, placeholder: "Επιβεβαίωση Νέου Κ.Πρόσβασης", name: "password_confirmation" %></p></center>
<center><%= f.submit "Αποθήκευση", class: 'log_in_button' %><center>
<% end %>
Console output
Started POST "/users/change_password" for 127.0.0.1 at 2020-08-10 01:13:18 +0300
Processing by UsersController#change_password as HTML
Parameters: {"authenticity_token"=>"ORVdeLRZYMjP7XIMqligykYH7YqnjzprTpQnCl3G9XPj36hgEEcC+C/Y1F6Tp3QTOVrheaYD/SZM0BX+i3YERQ==", "old_password"=>"[FILTERED]", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "commit"=>"Αποθήκευση"}
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
↳ app/controllers/users_controller.rb:76:in `change_password'
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."username" = $1 LIMIT $2 [["username", "mauras"], ["LIMIT", 1]]
↳ app/models/user.rb:36:in `update_password'
(0.2ms) BEGIN
↳ app/models/user.rb:41:in `update_password'
User Exists? (0.4ms) SELECT 1 AS one FROM "users" WHERE "users"."username" = $1 AND "users"."id" != $2 LIMIT $3 [["username", "mauras"], ["id", 1], ["LIMIT", 1]]
↳ app/models/user.rb:41:in `update_password'
User Exists? (0.4ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = $1 AND "users"."id" != $2 LIMIT $3 [["email", "asdas#adasd.com"], ["id", 1], ["LIMIT", 1]]
↳ app/models/user.rb:41:in `update_password'
(0.3ms) ROLLBACK
↳ app/models/user.rb:41:in `update_password'
Rendering users/change_password.html.erb within layouts/application
Rendered users/change_password.html.erb within layouts/application (Duration: 0.8ms | Allocations: 365)
[Webpacker] Everything's up-to-date. Nothing to do
Completed 200 OK in 608ms (Views: 6.3ms | ActiveRecord: 2.1ms | Allocations: 10770)
also try user.save still nothing,

Rails 5 Enum With Select Field Not Saving

I understand that this has been asked many times, but for some reason none of the other solutions worked for me. I'm still unable to save a field with an enum on update.When I pass a non-enum value, like first_name, with the same form, it updates just fine, but the enum value, gender, never saves even though it shows that it is...
View:
<%= form_for(#patient, url: patient_path(params[:id])) do |f| %>
<%= f.fields_for :role do |r| %>
<%= r.fields_for :user do |u| %>
<div class="keyvalue">
<div class="key"><p>Gender</p></div>
<div class="value">
<%= u.select :gender, User.genders.map { |key, value| [key.humanize, key] }, include_blank: '-Select A Gender-' %>
</div>
<div class="push"></div>
</div><!--keyvalue-->
<% end %>
<% end %>
<% end %>
Controller:
def update
#patient = Patient.find(params[:id])
if #patient.update(patient_params)
flash[:success] = "Patient's record has been updated."
redirect_to patient_path(params[:id])
else
flash[:error] = #patient.errors.full_messages.to_sentence
redirect_to patient_path(params[:id])
end
end
Log:
Parameters: {"utf8"=>"✓", "authenticity_token"=>"*********", "commit"=>"Update", "patient"=>{"role_attributes"=>{"user_attributes"=>{"first_name"=>"John", "middle_name"=>"Joseph", "last_name"=>"Doe", "date_of_birth"=>"1943-12-25", "gender"=>"male", "blood_type"=>"", "ethnicity"=>"", "marital_status"=>"", "id"=>"1"}, "id"=>"1"}}, "id"=>"1"}
Patient Load (0.1ms) SELECT "patients".* FROM "patients" WHERE "patients"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
(0.0ms) begin transaction
Role Load (0.1ms) SELECT "roles".* FROM "roles" WHERE "roles"."roleable_id" = ? AND "roles"."roleable_type" = ? LIMIT ? [["roleable_id", 1], ["roleable_type", "Patient"], ["LIMIT", 1]]
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
User Exists (0.1ms) SELECT 1 AS one FROM "users" WHERE "users"."username" = ? AND ("users"."id" != ?) LIMIT ? [["username", "dev"], ["id", 1], ["LIMIT", 1]]
SQL (0.3ms) UPDATE "users" SET "gender" = ?, "updated_at" = ? WHERE "users"."id" = ? [["gender", 0], ["updated_at", "2018-04-24 02:11:23.126843"], ["id", 1]]
(2.6ms) commit transaction
Redirected to http://localhost:3000/patients/1
Completed 302 Found in 10ms (ActiveRecord: 3.2ms)
Enum in User model:
enum gender: [:male, :female, :non_binary, :rather_not_say]
Migration:
t.integer :gender
The log shows no issue, it shows the gender field being updated, but if I go to the rails console it shows gender as nil

Rails 5 - form not updating - param is missing or the value is empty: tag

In my rails 5 app, I have a form (below) that is loading correctly, yet not updating. No notification of errors (should pass all validations (only on presence = true)).
Error
param is missing or the value is empty: tag
pointing to the tag_params method.
All help, suggestions, improvement, simplification welcome!
Controller
def update
tagable = detect_tagable
#tag = tagable.tags.find(params[:id])
#tag.update(tag_params)
render '_tag_update'
end
def tag_params
params.require(:tag).permit(:content, :location, :tagtype_id, annotation_attributes: { annotation_ids:[] }, document_attributes: { document_ids:[] })
end
Routes
Rails.application.routes.draw do
root 'dashboard#index'
devise_for :users
resources :users, :documenttypes, :tagtypes, :business_partners
resources :documents do
resources :comments, :tags
get "pdf", on: :member
end
resources :annotations do
resources :comments, :tags
get "pdf", on: :member
end
get "annotations/:id/annotate" => "annotations#annotate", as: 'annotate'
Form:
<%= simple_form_for [#tag.tagable, #tag], html: { class: 'form-horizontal', multipart: true },
wrapper: :horizontal_form,
wrapper_mappings: {
check_boxes: :horizontal_radio_and_checkboxes,
radio_buttons: :horizontal_radio_and_checkboxes,
boolean: :horizontal_boolean
} do |f| %>
<%= f.error_notification %>
<%= f.input :content, placeholder: 'Tagged content'%>
<%= f.association :tagtype, prompt: 'Select tag type', :collection => Tagtype.active.order(:name).where(:documenttype => #tag.tagable.documenttype_id) %>
<%= f.input :location, prompt: 'add as x1, y1, x2, y2' %>
<%= f.button :submit %>
<% end -%>
Rails server returns this (appears to be executed)
Started PATCH "/annotations/6/tags/46" for ::1 at 2016-10-15 16:15:09 +0200
Processing by TagsController#update as HTML
Parameters: {"authenticity_token"=>"7JMnYxy00zQXLIEfETSGWcMxPQFwNMYRJRyCeL9RMAQYtLygrf3UjamlZQdR/ajgTY2wH6DKOTeLE6yAUqbc6w==", "annotation_id"=>"6", "id"=>"46"}
User Load (1.8ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 6], ["LIMIT", 1]]
Annotation Load (1.1ms) SELECT "annotations".* FROM "annotations" WHERE "annotations"."id" = $1 LIMIT $2 [["id", 6], ["LIMIT", 1]]
Tag Load (1.0ms) SELECT "tags".* FROM "tags" WHERE "tags"."tagable_id" = $1 AND "tags"."tagable_type" = $2 AND "tags"."id" = $3 LIMIT $4 [["tagable_id", 6], ["tagable_type", "Annotation"], ["id", 46], ["LIMIT", 1]]
(0.2ms) BEGIN
Tagtype Load (0.5ms) SELECT "tagtypes".* FROM "tagtypes" WHERE "tagtypes"."id" = $1 LIMIT $2 [["id", 5], ["LIMIT", 1]]
(0.2ms) COMMIT
Rendering tags/_tag_update.html.erb within layouts/application
Annotation Load (0.4ms) SELECT "annotations".* FROM "annotations" WHERE "annotations"."id" = $1 LIMIT $2 [["id", 6], ["LIMIT", 1]]
Tagtype Load (1.0ms) SELECT "tagtypes".* FROM "tagtypes" WHERE "tagtypes"."active" = $1 AND "tagtypes"."documenttype_id" = 2 ORDER BY "tagtypes"."name" ASC [["active", true]]
Rendered tags/_tag_update.html.erb within layouts/application (43.0ms)
Rendered shared/_menu.html.erb (2.9ms)
Completed 200 OK in 220ms (Views: 203.3ms | ActiveRecord: 6.1ms)

Rails - Name can't be blank error when the input isn't blank

I get an error of 'Name can't be blank' and "Name only allows letters, numbers and '-'" when trying to update a name. This was working fine but I have just gone through it again while writing a test for it and realise it isn't working anymore, I can't figure out why or what has changed to break it.
Categories controller
def update
if #category.update category_params
redirect_to new_guide_category_item_path(#guide, #category)
flash[:info] = "Updated successfully"
else
render 'edit'
end
end
private
def category_params
params.require(:category).permit(:name, :template)
end
edit.html.erb
<%= render 'shared/error_messages', object: f.object %>
.....
<%= form_for([#guide, #category], url: guide_category_path) do |f| %>
<%= f.label :name, "Category name" %>
<%= f.text_field :name %>
<%= f.label :template, "Template" %>
<%= f.text_area :template, { :id => 'edit' } %>
<%= f.submit "Save", :value => "Save Template" %>
<% end %>
model
validates :name, presence: true, length: { maximum: 255 }, uniqueness: { scope: :guide_id, case_sensitive: false },
exclusion: { in: %w( guide guides category categories item items page pages post posts tag tags key keys item key item keys item-key item-keys item_key item_keys mod moderator mods moderators admin admins), message: "%{value} cant be taken." },
format: { with: /\A[a-zA-Z0-9 -]+\z/, message: "only allows letters, numbers, spaces and '-'" }
routes
resources :guides do
resources :categories, only: [:new, :create, :edit, :update] do
end
end
Anyone have an idea of what might be going wrong?
Edit added log output
Started PATCH "/guides/ghj/categories/ijijij" for ::1 at 2016-02-11 14:08:04 +1100
Processing by CategoriesController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"IqiUJ8wF8ZY4t8f91+t4aOMc9xenx/F2beKjKs9GY7JzLD6ZgPYDY1ueC2s+OIDL+PjROVtMe2+GvgYdan1CDQ==", "category"=>{"name"=>"ijijijddd", "template"=>""}, "commit"=>"Save Template", "guide_id"=>"ghj", "id"=>"ijijij"}
[1m[35mUser Load (0.2ms)[0m SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 1]]
[1m[36mGuide Load (0.1ms)[0m [1mSELECT "guides".* FROM "guides" WHERE "guides"."slug" = ? ORDER BY "guides"."id" ASC LIMIT 1[0m [["slug", "ghj"]]
[1m[35mCategory Load (0.1ms)[0m SELECT "categories".* FROM "categories" WHERE "categories"."slug" = ? ORDER BY "categories"."id" ASC LIMIT 1 [["slug", "ijijij"]]
[1m[36m (0.1ms)[0m [1mSELECT "category_item_keys"."name" FROM "category_item_keys" WHERE "category_item_keys"."category_id" = ?[0m [["category_id", 6]]
[1m[35m (0.0ms)[0m SELECT "check_category_item_keys"."name" FROM "check_category_item_keys" WHERE "check_category_item_keys"."category_id" = ? [["category_id", 6]]
[1m[36m (0.1ms)[0m [1mSELECT "category_item_keys"."name" FROM "category_item_keys" WHERE "category_item_keys"."category_id" = ? AND "category_item_keys"."key_type" = ?[0m [["category_id", 6], ["key_type", 1]]
[1m[35m (0.0ms)[0m SELECT "category_item_keys"."name" FROM "category_item_keys" WHERE "category_item_keys"."category_id" = ? AND "category_item_keys"."key_type" = ? [["category_id", 6], ["key_type", 2]]
[1m[36m (0.1ms)[0m [1mSELECT "category_item_keys"."name" FROM "category_item_keys" WHERE "category_item_keys"."category_id" = ? AND "category_item_keys"."key_type" = ?[0m [["category_id", 6], ["key_type", 3]]
[1m[35mGameModsRelationship Exists (0.1ms)[0m SELECT 1 AS one FROM "game_mods_relationships" WHERE "game_mods_relationships"."user_id" = ? AND "game_mods_relationships"."category_id" = 3 LIMIT 1 [["user_id", 1]]
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
[1m[35mCategoryItemKey Exists (0.1ms)[0m SELECT 1 AS one FROM "category_item_keys" WHERE ("category_item_keys"."name" IS NULL AND "category_item_keys"."guide_id" IS NULL) LIMIT 1
[1m[36mCategory Exists (0.1ms)[0m [1mSELECT 1 AS one FROM "categories" WHERE (LOWER("categories"."name") = LOWER('ijijijddd') AND "categories"."id" != 6 AND "categories"."guide_id" = 3) LIMIT 1[0m
[1m[35m (0.0ms)[0m rollback transaction
[1m[36mCACHE (0.0ms)[0m [1mSELECT 1 AS one FROM "game_mods_relationships" WHERE "game_mods_relationships"."user_id" = ? AND "game_mods_relationships"."category_id" = 3 LIMIT 1[0m [["user_id", 1]]
Rendered shared/_error_messages.html.erb (0.5ms)
Rendered categories/edit.html.erb within layouts/application (5.6ms)
Rendered layouts/_shim.html.erb (0.1ms)
Rendered layouts/_header.html.erb (0.7ms)
Rendered layouts/_footer.html.erb (0.1ms)
Completed 200 OK in 157ms (Views: 145.1ms | ActiveRecord: 1.1ms)`
You need to add error_messages helper tag in the partial. That handles all error messages and show it properly.
It looks like your database has an existing record with the same name. Try inputting a unique name in. In your model, it is checking for :uniqueness.

Resources