Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8783209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:46:16+00:00 2026-06-13T20:46:16+00:00

I’m new to RESTful design and confused: if I make PUT, GET or POST

  • 0

I’m new to RESTful design and confused: if I make PUT, GET or POST to a same resource, say, /weblogs/myweblog, how should I write in the route.rb, and related controller?
Does the following works?
In route.rb

match 'weblogs/myweblog/new' => 'weblogs#create_new_blog'
match 'weblogs/myweblog/edit/:id' => 'weblogs#edit_blog' 
.
.

In weblogs_controller.rb

def create_new_blog
   ...
end

def edit_blog
  params[:id]..
  ....
end

and confused if I want to do GET/PUT/POST on the same resource, if their URL is same but only HTTP request is different, how to write different operations in the controller?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:46:17+00:00Added an answer on June 13, 2026 at 8:46 pm

    In general it’s best to define your routes in terms of resources, so if you have a resource named webblog, your routes can be defined using just:

    resources :weblogs
    

    If you check the routes generated by this (with rake routes), you will see that it defines a standard set of mappings from GET, PUT, POST and DELETE actions on urls to controller actions:

       webblogs GET    /weblogs(.:format)         weblogs#index
                POST   /weblogs(.:format)         weblogs#create
    new_webblog GET    /weblogs/new(.:format)     weblogs#new
        webblog GET    /weblogs/:id(.:format)     weblogs#show
                PUT    /weblogs/:id(.:format)     weblogs#update
                DELETE /weblogs/:id(.:format)     weblogs#destroy
    

    These routes will map to standard controller actions index, create, new, show, etc.

    If for whatever reason you want to define routes without using resources, you can define them separately:

    get '/weblogs' => 'weblogs#index'
    get '/weblogs/new' => 'weblogs#new'
    get '/weblogs/:id/edit' => 'weblogs#edit'
    put '/weblogs/:id' => 'weblogs#update'
    ...
    

    By defining routes with get, put etc. you can map a single URL to multiple controller actions, e.g. like this:

    get '/weblogs/myweblog' => 'weblogs#show_myweblog'
    put '/weblogs/myweblog' => 'weblogs#update_myweblog'
    post '/weblogs/myweblog' => 'weblogs#create_myweblog'
    destroy '/weblogs/myweblog' => 'weblogs#destroymy_weblog'
    

    This will map the URL /weblogs/myweblog to the method show_myweblog for a GET request, update_myweblog for a PUT request, create_myweblog for a POST request, and destroy_myweblog for a DELETE request.

    Alternatively, using the standard resources, you can pick and choose which routes you want from the full set with the only option:

    resources :weblogs, only: [:show, :edit]
    

    See the documentation for more details. I hope this answers your question, if not please provide more details on what you want to do in the comments.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I'm outputting a post title and in our database, it's Hello Y’all
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.