Home>
Developing a photo posting app.
I have written that the action new works when the create action cannot save it.
def new
@photo = Photo.new
@page_name ='Post page'
end
def create
@photo = Photo.new (photo_params)
if @ photo.save
redirect_to root_path
else else
render: new
end
end
http: // localhost: 3000/photos/new
From
http: // localhost: 3000/photos
The layout is distorted ...
I knew that I should change the description of routes.rb in another article, but I don't know how to write it ...
resources: photos do
resources: comments, only :: create
resource: favorites, only: [: create,: destroy]
collection do
get'search'
end
end
I saw in the article that form_with also needs to be modified, but I didn't know where to change when the article was old and compared to my own.
<% = form_with (model: @photo, local: true) do | f |%>
<% = render'shared/error_messages', model: f.object%>
If i know, please answer!
-
Answer # 1
Related articles
- ruby on rails - about the matter that does not transition to the detail page
- ruby on rails - about the description in applicationjs
- ruby on rails - about switching screen display on multiple models
- ruby - about accelerating heroku's rails app
- ruby on rails - about the legitimacy of db design
- ruby on rails - about image distribution on heroku and s3
- ruby - about how to save db with rails devise
- ruby on rails - about request spec of rspec about test code at login
- about validation of ruby on rails
- about description of manifest file of ruby on rails
- ruby on rails - about conditional branching using elsif
- ruby on rails - about rails composite indexes
- ruby on rails 5 - about lint/syntax error of rubocop
- ruby on rails 6 - rails tutorial chapter 14 about follow, unfollow, following? methods
- ruby - [rails] about nameerror
- ruby - rails render flash doesn't work
- ruby - about the delete function in rails
- ruby on rails - about nomethoderror in skilscontroller # create
- ruby - about rails routing
Related questions
- javascript - i want to eliminate error 404
- ruby - i want to make a graph of the values retrieved by the each statement with chart kick
- ruby - about rails controller new action
- ruby on rails - no response when trying to launch ec2 rails
- ruby - sns login i don't know how to install twitter api
- ruby on rails - i want to implement a login function using devise
- ruby - i created an intermediate table, but no data is saved in the intermediate table
- i want to display a preview by posting multiple javascript images
- javascript - i want to display a preview on the image post edit page
- ruby - i want to be able to purchase by pressing the purchase button
wrong.
new
ToindicateJust the URLcreate create
The thing is used as it is.Please review the description such as CSS and file reference that "the layout is disturbed".