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!