Home>
Assumptions/I want to realize

Since I learned ruby ​​&rails in 2 months, I knew what I was saying a one-to-many, many-to-many relationship, but I can't make it without looking at it.
I decided to create an "instruction/contact application for internal use" at work

What i am trying to do

When sending instructions from the store manager (user) to employees (braff)
Enter the name of the employee who will give instructions in the drop-down
Enter and submit the instructions (comment)
The store manager has a list of instructions sent by him
Employees want to be able to see the comments they have received.

I am trying to use the shape of Micropost as it is.

Error message

Instructions and employee entry fields are ready
I got an error when I hit send.

Applicable source code

MicropostsController

class MicropostsController</pre>
<p><br />
toppages/index</p>
<pre><code data-language = "Rails"><% if logged_in?%>
  
    
      <% = form_with (model: @micropost, local: true) do | f |%>
        
          <% = f.label: title, 'Instruction content'%>
          <% = f.text_area: comment, class: 'form-control', rows: 5%>
          <% = f.label: title, 'Who will you send it to? '%>
          <% = f.select: staff, [["Ishizaki", "isizaki"], ["Kikuchi", "kikuti"]],: prompt =>"Please select"%>
        
        <% = f.submit 'Send', class: 'btn btn-primary btn-block'%>
      <% end%>
    </aside>
    
      <% = render 'microposts/microposts', microposts: @microposts%>
    
  
<% else%>
  
    
       Welcome to the Microposts 
      <% = link_to 'Sign up now!', signup_path, class: 'btn btn-lg btn-primary'%>
    
  
<% end%>

MicropostsController

def micropost_params
    params.require (: micropost) .permit (: content)
  end
def micropost_params
    params.require (: micropost) .permit (: comment,: staff)
  end


I tried to change to but was not.

Supplemental information (FW/tool version etc.)

After this, employees want to be able to view only the comments that have been sent to them

rails g model Micropost comment: string user: references staff: string


Then, I tried to have the sender (user) and the person (staff) receiving the instruction for the comment (comment)
I don't know how to display the same name as user and staff
If there is something that can be helpful, please let me know.

  • Answer # 1

    Please check Micropost migration.
    Probably it is made with content instead of comment.
    Please match the name

  • Answer # 2

    Because I was making a text imitation
    If you check the text and program again,

    models/micropost validation was now content.
    And if you test again, you will get an error again
    This time, there was a place in the view/microposts/_microosts where content was entered by mistake.

    After correcting the above two locations, I successfully posted.
    It was a rudimentary mistake, but it became a study.
    Thank you very much.

  • Answer # 3

    Because I was imitating text
    If you check the text and program again,

    models/micropost validation was now content.
    And if you test again, you will get an error again
    This time, there was a place in the view/microposts/_microosts where content was entered by mistake.

    After correcting the above two locations, I successfully posted.
    It was a rudimentary mistake, but it became a study.
    Thank you very much.