Forum: Ruby on Rails Doing POST and PUT in a Sinatra application

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Vipul P. (Guest)
on 2009-03-12 07:36
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-

[code]
get '/' do
    @CNs = Data.all()
    erb :index
end
[/code]

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 ?

[code]
post '/addnew/:id' do |id|
    erb :addnew
end
[/code]

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 [B]erb :addnew[/B]. 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 ;
This topic is locked and can not be replied to.