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 messageInstructions and employee entry fields are ready
I got an error when I hit send.
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.
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
-
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.
Related articles
- ruby - i get an error when i run rails db: seed
- ruby - i get a #routing error
- ruby on rails - when i run rails s, i get
- macos (osx) - i get an error when i open the terminal
- ruby on rails - error when vagrant up
- i get an error when packaging ue4
- url:i get an error when i put the url on tex,
- sass - i get a name error in ruby on rails
- python - i get a 500 error when outputting csv
- ruby - i entered secret_key_base, but http error 500 cannot be resolved
- ruby on rails 6 - when i press new user registration, i get an error of no route matches [get] "/ users"
- ruby on rails - i get an error without being created
- ruby on rails - error when implementing rails6 follow function
- ruby - i get an error with a single test code for a model
- ruby - i got a routing error when i sent a comment
- ruby on rails - nomethoderror in itemscontroller # new error
- ruby on rails - i get an error in a program that changes over time
- c - i get an error message
- ruby on rails - i get an error with rails db: create
- ruby error code
- i want to convert chinese numerals to alphanumeric characters using gsub with ruby
- [ruby] i'm having trouble with nomethoderror
- ruby - if you try to make the value of the array (json) sent on the vue side a strong parameter, a nomethoderror error will occu
- ruby - i want to display the edit button and delete button on the index page
- ruby - i want to generate a random password (mixed alphanumeric characters)
- ruby - sass :: syntaxerror on rails s
- ruby - i want to display new posts i made on the top page only for myself
- ruby - [rails] i want to deploy a rails application using elastic beanstalk
- [javascript] i want to switch the display/non-display of the input form
- ruby - dealing with validation errors when rendering rails apps (definition of instance variables)
Please check Micropost migration.
Probably it is made with content instead of comment.
Please match the name