No route matches [POST] "/home/new"

Hello all, I'm new to ruby and I am having trouble with adding new data
(name, height, weight, etc). Everytime I try to save my data, I get
this error:

No route matches [POST] "/home/new"
Rails.root: C:/Users/Jeffrey/blog



"commit"=>"Save @input"}

I am able to view index and enter the information, but when I submit, I
get this problem. Any help would be appreciated! Thank you

I’m pretty new to ruby as well but I think the problem is that the Rails router doesn’t know what to do with a POST request to “/home/new”. I think you just have to add this line to routes.rb:

post ‘home/new’, to: ‘home#new’

Like I said I’m a newbie myself so I’d love it if someone could correct me if I’m wrong or let me know if I got it all.

I dont get the error, but when I try to save the data, it seems to
reload the page again, and the data doesnt get saved. It doesn't appear
at all when i go back to /home

You have an error in your controller

You have in the create action, rather than

Additionally it is convention to use the same name of the variable as the model, so you should really use @person =, rather than @input =

You can always check what routes are recognised by use of the 'rake routes' command

Hello, thanks to you I have been able to add in the data. I also changed
and cleaned up the code and used the convention with regards to the
variables. I have another question regarding the destroy/deleting data,
when I click on delete, it directs me to show where i can view the data,
but does not delete anything. Here is my updated code

class PeopleController < ApplicationController

    def index
        @people = Person.all

    def show
        @person = Person.find(params[:id])

    def new
        @person =

    def create
        @person =
        redirect_to :action => :index

    def edit
        @person = Person.find(params[:id])

    def update
        @person = Person.find(params[:id])
        redirect_to :action => :show, :id => @person

    def destroy
        @person = Person.find(params[:id])
        redirect_to :action => :index

    def person_params
        params.require(:person).permit(:name, :weight, :height, :color,

Look in log/development.log and when you click delete you should see
the request and whether it is calling the destroy method. You can
insert diagnostic code in your methods using stuff like
     def destroy
 "In destroy"
         @person = Person.find(params[:id])
         redirect_to :action => :index

and your logger output will appear in the log file.


In the delete link, you need to use the delete method-Rails now expects a delete verb, where as your code is generating a get I believe

Mike S. wrote in post #1180984:

In the delete link, you need to use the delete method-Rails now expects
a delete verb, where as your code is generating a get I believe


<%= link_to 'Delete', :controller => "people", :action
=> "destroy", :id => e, :method => :delete %>

Sent from my iPhone

I have the changes and it just directs me to the show page displaying
the info like before. When I go back to /people the data is still there.
In the logs it says:

Started GET "/people/1?method=delete" for ::1 at 2016-01-27 17:38:42
Processing by PeopleController#show as HTML
Parameters: {"method" => "delete", "id" => "2"}
Person Load (0.5ms) SELECT "people".* FROM "people" WHERE "people"."id"
= $1 LIMIT 1 [["id", 2]]
Rendered people/show.html.erb within layouts/application (0.0ms)
Completed 200 OK in 26ms (views: 25.0 ms | ActiveRecord :0.5 ms)


Started GET "/stylesheets/default.css" for ::1 at ..


Started GET "/javascripts/default.js" for ::1 at ..

I did some searching and I was wondering if it is the javascript because
I changed the application.html.erb from

<%= stylesheet_link_tag 'application'
  <%= javascript_include_tag 'application'

and replaced 'application' to 'default' since I am on windows and the
'application' was causing problems

I assume therefore you also renamed the /app/assets/javascripts/application.js to default.js

sorry I do not develop under Windows, so cannot be sure if there is not some other issue related to that, there are a number of shortcomings when you use rails on Windows, but that is mainly gem support, not JavaScript

Just as an interest, can you create a blank application, and do something like

rails g scaffold something field1 field2

And then check the code it generated in the views - I doubt it is different on Windows, but I cannot be sure

Also run the app and see if you can add/delete ok

I actually did not rename it to default.js, but when I try to do that
and access localhost I get an error:

ExecJS::ProgramError in People#index
Showing: /app/views/layouts/application.html.erb where line #6 raised:
TypeError: Object doesn't support this property or method

and line 6 which is:

<%= javascript_include_tag 'default', 'data-turbolinks-track' => true %>

I tried using scaffold and it does the same thing, it can add, but it
does not delete, it directs me to /posts/1 where it just displays the
data for id:1

The code in views is different from mine:


<td><%= link_to 'Destroy', post, method: :delete, data: { confirm: 'Are
you sure?' } %></td>


  def destroy
    respond_to do |format|
      format.html { redirect_to posts_url, notice: 'Post was
successfully destroyed.' }
      format.json { head :no_content }

Hm, I found this from stackoverflow

and if I remove //= require_tree and //= turbolinks

then I can include application.js and the add/delete does work for
scaffold, but I still cannot remove people

So something is definitely broken in your Javascripts, or the views - the scaffold code there is what I am used to seeing, just referencing the record rather than the explicit ID you pass in.

I am at a loss as to why Windows is complaining when you change the name, or indeed why it would not respond to the standard name of application.js - which has no meaning to Windows that I am aware of