Cannot save data in intermediate table and member tableError message
Applicable source code
ArgumentError in CommentsController # new Unknown key:: allow_destory. Valid keys are:: allow_destroy,: reject_if,: limit,: update_only
class MemberComment</pre> <pre><code data-language = "model">class Member</pre> <pre><code data-language = "model">class Comment</pre> <pre><code data-language = "controller">class CommentsController</pre> <pre><code data-language = "Haml">. contents .form = form_for @comment do | f | = fields_for: members do | m | = m.collection_select: member_id, Member.all,: id,: name, include_blank: true = f.text_field: place, class: 'form__place', placeholder: 'Please enter a tourist destination' = f.text_area: text, class: 'form__review', placeholder: 'Please enter your comments (comments)' = f.text_field: image_url, class: 'form__image', placeholder: 'Paste image URL' = f.submit
validate: member_comment_id, presence: true for intermediate table model
I get a SyntaxError error
Answer # 1
1) It cannot be understood that Comment and Member are many-to-many.
You can see that Membar creates multiple comments.
Does the comment involve multiple members?
2) Although there is a method of creating an intermediate table to create a relationship,
There is also a method of assigning related members.
@ comment.members = members (and so on)
I think this is easier.
3) How is the associated member determined?
If you are a comment creator, you do not need to enter it on the new screen
If the person creating the comment chooses from existing members,
= fields_for (@member) do | member | = member.text_field: name,
It is better to select from the member by select with
- ruby - create 3 or more columns in the intermediate table | db design
- ruby on rails - rails intermediate table save
- ruby - i want to save multiple records in an intermediate table in one process
- ruby on rails - data cannot be saved in the intermediate table (parameters cannot be passed)
- ruby - i want to get the value of the intermediate table using the each statement
- ruby on rails 6 - rails does not save to intermediate table
- ruby - [rails/rspec] intermediate table model test does not pass
- ruby - how to get the value of the intermediate table
- ruby - i want to store the ids of user and group in an intermediate table
- ruby - i created an intermediate table, but no data is saved in the intermediate table
- ruby on rails - get data for rails intermediate table
- ruby on rails - round-robin league table design
- ruby - [rails] cannot refer to the relation destination table
- ruby - i don't know how to retrieve the values of the array in the intermediate table
- mysql - [sql] cannot create table
- sql execution result cannot be received and displayed in ruby
- ruby - account id cannot be saved with stripe
- ruby - gtk3 cannot be installed
- ruby on rails 5 - the time notation cannot be written normally
- ruby - [rails] when rails s is executed, an error "cannot load database configuration" appears and it is forcibly term
- ruby - undefined method `model_name'for nil: i got an error in nilclass and want to know where the cause is
- ruby - i want to save it in two tables when posting with form_with
- ruby - i want to enclose child elements (: title etc) in model_params of controller
- ruby - passing variables using render partial
- [ruby] i'm having trouble with nomethoderror
- i'm having trouble with ruby's word bingo algorithm
- ruby - unable to open rails server
- ruby - if i include the'omniauth-facebook'gem, do i need to install the'omniauth' gem as well?
- ruby - even if each statement is used, the contents of the db cannot be displayed in order and an error occurs
- ruby - [search function] acquisition of products associated with users