score:1
Accepted answer
As we discussed in the comments, the CustomersController
actually ends after the create
method, so the update
, destroy
, customer_params
, and set_customer
methods all fall outside of the CustomersController
. So, moving the third end
after the create
method to end of the file should fix it. Your controller should look like:
class CustomersController < ApplicationController
before_action :set_customer, only: [:update, :destroy]
def index
@customers = Customer.all
end
def create
@customer = Customer.new(customer_params)
if @customer.save
render json: @customer
else
render json: @customer.errors, status: :unprocessable_entity
end
end
# note that there was a third end here
def update
if @customer.update(customer_params)
render json: @customer
else
render json: @customer.errors, status: :unprocessable_entity
end
end
def destroy
@customer.destroy
head :no_content
end
private
def customer_params
params.require(:customer).permit(:name, :lastname, :mobile, :phone, :email, :address, :zip, :city, :state)
end
def set_customer
@customer = Customer.find(params[:id])
end
end # end moved to here
Source: stackoverflow.com
Related Query
- Reactjs and rails implementation error on form 404 not found on the server side
- React, Node, Mongodb : My image file is not being served from backend and trying to render it on the React side throws 404 not found
- What's the best way to deal with an error in the server side and in the client side using nodejs + express
- how to solve the error that fs module is not found when used react and next.js
- Css and Js not working after deploying the next+react project to server side
- React form returns 404 not found when trying to sign up with Devise Rails API
- redux Form 7.4.2 Server side validation not working with axios , gives error Unhandled Rejection (SubmissionError): Submit Validation Failed
- I am not able to read authorization headers on server side with reactjs fetch and nodejs as REST apis project
- ReactJS Not Found The requested URL /AboutMe was not found on this server
- The root path "/" does not match the reactjs declared route on server side rendering, when webpack middleware is used
- Input an array from a form and post it to the server in ReactJs
- How to retrieve and display images in reactjs that are stored on the server side using multer and the path is stored in the database
- Reset a form in React and console log the details on the server side
- 'npm start' gives an error and does not start the development server
- How to reset the form and login error message in reactjs
- React Router can't configure URLs on localhost and remote. Receiving 404 not found error
- reactjs app showing 404 not found in nginx server
- Having a null violation error when posting from my frontend to the server side in node.js and react and sequelize
- React Error The requested URL was not found on this server when refreshing
- How to post new object to the existing json (clientside ReactJS + server side NodeJS and Express)
- react.js application showing 404 not found in nginx server
- React JS Server side issue - window not found
- Webpack 4 and react loadable does not seems to create correct chunk for server side rendering
- How to display 404 when URL doesn't match any route and when the URL contains /#/ using ReactJS
- How to avoid getting error 'localStorage is not defined' on server in ReactJS isomorphic app?
- How to do POST in FORM Submit using reactjs and pass the object value into REST service?
- Reactjs Warning: input is a void element tag and must not have `children` or use `props.dangerouslySetInnerHTML`. Check the render method of null
- Next JS npm start app load 404 page not found error for physical pages
- Gatsby window not available during server side rendering build error
- How to server side redirect to other page without reloading the page and still keeping the url in Nextjs app?
More Query from same tag
- How to fetch sequence api calls where second api call need particular data from first api call result using react hooks?
- StencilJS error with React output target - You may need an additional loader to handle the result of these loaders
- React testing library in Typescript
- ReactJs only rendering one img element from mapping an array of URLs
- Can't reach the variable
- mapping props is undefined when passed into component
- How to create a new instance of a model along with relations in redux-orm?
- React, adding an animation when removing a class from an element?
- how to preventDefault in componentDidMount()
- how to make javascript scrollIntoView smooth?
- Allowing only positive numbers with decimal places
- React input onChange lag
- Uploading images with fetch to Express using Multer
- Anchor Link Libraries not working at all in my React project
- How to iterate over and test different child elements within an element in cypress?
- How to properly delete object subfields when dispatching a new redux action?
- useEffect cleanup function? Memory leak error
- react-app-rewired requiring giving mini-css-extract-plugin
- How do you wrap four cards around a centered card?
- Debugging To many rerenders error react redux
- TypeError: variable is undefined despite being able to log the variable correctly
- Render a consumed API on Django to React Front-end
- Too Many Rerenders - Storing useLocation().state variable in a useState() variable
- Programmatically navigate using React router
- With Axios.Get, You have provided an out-of-range value `value` for the select component
- React useState async setter doesn't update value passed as props
- Try to map through an enum in TS with Object.entries<T>(Enum).map(), but only works with string based enums?
- Camel cased CSS in Styled Components or Emotion for regular React?
- How set value of Select before onChange will execute?
- ReactJs - state is rendered properly but inside method, shows wrong value