startram
Startram
It's time to take the rails into space...
Installation
Since crystal doesn't fetch dependencies of dependencies you'll have to add startrams dependencies on top of startram itself in your Projectfile
.
deps do
github "spalger/crystal-mime"
github "dbackeus/activesupport.cr"
github "dbackeus/startram"
end
Usage
(visionary usage as model layer persistance methods are not actually there from scratch)
require "startram"
class User
include Startram::Model
field :name, String
field :age, Integer
end
class UsersController < Startram::Controller
def index
@users = User.all
view :index
end
def new
@user = User.new
view :new
end
def edit
@user = User.find(params.int("id"))
view :edit
end
def create
@user = User.new(user_params)
if @user.save
redirect_to users_path
else
view :new
end
end
def update
@user = User.find(params.int("id"))
if @user.update_attributes(user_params)
redirect_to user_path(@user.id)
else
view :edit
end
end
def destroy
@user = User.find(params.int("id"))
@user.destroy
redirect_to users_path
end
private def user_params
User.params(params, :name, :age)
end
end
class MyApp < Startram::App
routes do
resources :users
end
end
app = Startram::App.new(root: __DIR__)
app.serve
Development
Take advantage of the examples to test your new features.
Run specs as usual with crystal spec
.
Contributing
- Fork it ( https://github.com/dbackeus/startram/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- dbackeus David Backeus - creator, maintainer
- Various contributions borrowed from Rack, Rails and Amethyst projects
Repository
startram
Owner
Statistic
- 4
- 1
- 0
- 0
- 0
- over 8 years ago
- July 31, 2015
License
MIT License
Links
Synced at
Wed, 15 May 2024 17:14:39 GMT
Languages