# Doing POST and PUT in a Sinatra application

**URL:** <https://www.ruby-forum.com/t/doing-post-and-put-in-a-sinatra-application/162630>\
**Category:** Rails\
**Created:** [March 12, 2009, 6:36am UTC](https://www.ruby-forum.com/t/doing-post-and-put-in-a-sinatra-application/162630 "2009-03-12T06:36:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vipulpathak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/fbc32d/32.png) [@vipulpathak](https://www.ruby-forum.com/u/vipulpathak)\
**Post date:** [March 12, 2009, 6:36am UTC](https://www.ruby-forum.com/t/doing-post-and-put-in-a-sinatra-application/162630/1 "2009-03-12T06:36:46Z")

</div>

Hello,

I am using Sinatra to write an application that would act on GET, POST,  
PUT and DELETE actions. I have coded the GET part as follows-

```auto
get '/' do
    @CNs = Data.all()
    erb :index
end
```

The index.erb in ./views has all the rendering logic.

Thus, the get block calls the index.erb file. How should POST and PUT  
should be coded ?

```auto
post '/addnew/:id' do |id|
    erb :addnew
end
```

If addnew.erb will POST and action will be ‘/addnew/5’, then it will  
call the post block again, Isn’t ?

I think, I shouldn’t call the erb :addnew. Instead something else  
should be done.

I am sure this is a very basic thing and a lot of people could have gone  
through this step earlier. Any suggestion ?

Thanks in Advance,

+Vipul ;
