Skip to content

Instantly share code, notes, and snippets.

@nfriend21
Created October 21, 2012 18:11
Show Gist options
  • Save nfriend21/3927942 to your computer and use it in GitHub Desktop.
Save nfriend21/3927942 to your computer and use it in GitHub Desktop.
this is the main script
hello from the view
<form action="/form" method="post">
<input type="text" name="name">
<input type="submit">
</form>
require 'sinatra'
require 'sinatra/activerecord'
require "sinatra/reloader" if development?
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:database => 'sinatra_application.sqlite3.db'
)
class User < ActiveRecord::Base
attr_accessible :name
end
get '/' do
@nick = Time.now
erb :index
end
get '/hello/:name' do
"Hello there, #{params[:name]}."
end
get '/form' do
erb :form
end
post '/form' do
name = params[:name]
User.create(:name => "#{name}")
#@user.name = params[:name]
#@user.save
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment