R
R
Roman2016-11-23 17:57:17
Ruby on Rails
Roman, 2016-11-23 17:57:17

How to draw the form correctly?

the form code is in app/views/request/new.erb:

<%= simple_form_for(@request, remote: true) do |f| %>
  <%= f.input :phone, prompt: "Телефон" %>
  <%= f.input :email, prompt: "email" %>
  <%= f.button :submit %>
<% end %>

when rendering the form, when trying to access the page localhost:3000:
undefined method `requests_path' for class many digits
Did you mean? request

Request_controller.rb controller code
class RequestController < ApplicationController

  def new
    @request = Request.new
  end

  def create
    @request = Request.create(request_params)
    respond_to do |format|
      format.html
      format.json{render :json => @request}
    end
  end

  def update
    @request.update(request_params)
  end

  private
    def request_params
      params.require(:request).permit(:email, :phone)
    end
end

in routes.rb:
root 'request#new'

  post '/request/create' => 'request#create'

Actually, what do I want? I want the form from this page to be sent to the request controller to the create method.
what requests_path does it not see?
how to make it see?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anna Buyanova, 2016-11-23
@losaped

Better in routes.rb :
And Request s Controller

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question