Home>
I'd like to delete data with the destroy_all method for a related model in Rails5 implementation, but I'm getting an error.
class Library</pre>
<p><br />
When destroy_all is expected in the above code, the following error appears in the corresponding line.</p>
<pre><code>ActiveRecord :: StatementInvalid in Admin :: LibrariesController # update
PG :: SyntaxError: ERROR: zero-length delimited identifier at or near "" "" LINE 1: ... brary_translations "WHERE" library_translations "." "= $1 ^: DELETE FROM" library_translations "WHERE" library_translations "." " = $1
Extracted source (around line # 142):
141 def set_translations
142 self.ndl_library_translations.destroy_all
143 end
Since it is difficult to find a solution, it would be greatly appreciated if you could provide an answer to the error.
Addition:
Add each table definition
Table "public.libraries"
Column | Type | Modifiers
------------------------------ + ------------------- ----- + -------------------------------------------- ----------------
id | integer | not null default nextval ('libraries_id_seq' :: regclass)
name | text |
code | text |
url | text |
locale | character varying (255) |
lat | character varying (255) |lng | character varying (255) |
zip_code | character varying (255) |
prefecture | text |
address_line | text |
telephone_number | character varying (255) |
fax_number | character varying (255) |
ill_section_name | text |
ill_staff_name | text |
ill_staff_name_transcription | text |
director_name | text |
ill_reception_email | character varying (255) |
ill_availability | integer |
ill_method_email | integer |
ill_method_fax | integer |
ill_restriction | text |
ill_range | text |
ill_limit_number | text |
ill_period | text |
ill_letter | text |
ill_letter_format | text |
ill_official_stamp | text |
ill_method_fax_memo | text |
ill_memo | text |
ill_acceptance_time | text |
ill_carriage_load | text |
ill_returning_condition | text |
ill_book_inquiry | text |
ill_inquiry | text |
ill_special_memo | text |
ill_regulation | text |ill_handling_condition | text |
ill_priority | integer |
data_provide | boolean |
ill_information | text |
contact_email | character varying (255) |
ill_request_email | character varying (255) |
ill_notify_email | character varying (255) |
Indexes:
"libraries_pkey" PRIMARY KEY, btree (id)
Table "public.library_translations"
Column | Type | Modifiers
---------------- + ------------------------ + -------- -------------------------------------------------- -------------
id | integer | not null default nextval ('library_translations_id_seq' :: regclass)
library_id | integer | not null
locale | character varying (255) | not null
name | text | not null
Indexes:
"LIBRARY_TRANSLATIONS_IDX2" btree (library_id, locale)
Resolution added:
Table "public.library_translations"
Column | Type | Modifiers
---------------- + ------------------------ + -------- -------------------------------------------------- -------------
id | integer | not null default nextval ('library_translations_id_seq' :: regclass)
ndl_library_id | integer | not null
locale | character varying (255) | not null
name | text | not null
Indexes:
"library_translations_pkey" PRIMARY KEY, btree (id)
"LIBRARY_TRANSLATIONS_IDX2" btree (ndl_library_id, locale)
-
Answer # 1
Related articles
- ruby on rails undefinde method doesn't work
- ruby on rails: undefined method ʻuser'for nil: about nomethoderror of nilclass
- the ruby on rails each method does not repeat well
- ruby on rails - [rails] i want to make it a helper method
- ruby on rails - [rails] i want to use each statement in a helper method
- ruby - not saved with rails new save method
- ruby on rails - undefined method `merge'for
- ruby on rails 5 - undefined method `tomorrow'for 00: i would like to know how to solve bigdecimal
- ruby - undefind method chart kick in rails production environment
- ruby on rails - ndefined method `name'for nil: nilclass error is output
- ruby on rails - i don't know where to check the method
- ruby - no method error rails
- ruby on rails - undefined method `if'for ~
- ruby on rails 6 - undefined method `id'for: article: symbol resolution in rails
- ruby - unable to save comments in db (rails)
- ruby - rails: fattachment_field gives undefined method error
- ruby - the last db setting doesn't work when deploying rails app on aws
- ruby on rails 5 - the path is changed by redirect_to of rails
- ruby on rails - description of rails packagejson
- ruby on rails - i want to change from the state where only one posted image is displayed to the state where two posted images ar
Trends
WHERE "library_translations". "", so is the association column undefined? I suspected, but there are.
Try the following
1) Put
belongs_to: library
in LibraryTranslation2) Stop destory_all and try delete_all