3 ms·
So, instead of having multiple routes, with this method you're locked into one route per action.
by chrisbroadfoot 18y ago
So, instead of having multiple routes, with this method you're locked into one route per action.
- delano 18y agoThat's not true. Have you looked at Sinatra? It's gorgeous. All URI definitions can (and should) be placed in a single .rb file. get '/content/:id' do header 'Content-Type' => 'text/html; charset=utf-8' # Get content using params[:id] if (!@content.empty?) erb :show else redirect '/' end end get '/newstuff' do header 'Content-Type' => 'text/html; charset=utf-8' login_required # Do stuff erb :new, :layout => :layout_admin end post '/newstuff' do header 'Content-Type' => 'text/html; charset=utf-8' login_required @summary = Summary.new( :date => Time.now, :title => params[:title], :author => params[:author], :worthwhile => params[:worthwhile] ) # Save content erb(:new, :layout => :layout_admin) end