Transitioning from Ruby on Rails to Spruce
Ruby on Rails is a full-stack framework that uses Ruby, while Spruce is built on TypeScript. This guide will assist you in drawing parallels between Rails development and Spruce’s architecture, helping you understand how to apply your existing Rails knowledge in Spruce.
Key Differences between Ruby on Rails and Spruce Development
Ruby | Spruce | |
---|---|---|
Programming Language | Ruby | TypeScript |
IDE | RubyMine, VS Code | Visual Studio Code |
App Lifecycle | No direct equivalent; controlled by frameworks like Rails | No Equivalent |
UI Design | N/A for CLI; Rails for web views | Heartwood, ViewControllers |
Event Handling | Observer pattern, Callbacks in Rails | Mercury |
Data Persistence | ActiveRecord in Rails | Data Stores |
Error Handling | Begin-Rescue | Try-Catch Blocks, SpruceErrors |
Testing | RSpec, Minitest | TDD by the 3 laws |
User Authentication | Devise (Rails) | Mercury, Authenticator |
User Permissions | Pundit, Cancancan (Rails) | Mercury, Authorizor |
Programming Language
Ruby
Coming soon...
Spruce
import {
AbstractSkillViewController,
CardViewController,
ViewControllerOptions,
buildSkillViewLayout,
SkillView
} from '@sprucelabs/heartwood-view-controllers'
export default class RootSkillViewController extends AbstractSkillViewController {
public static id = 'root'
protected cardVc: CardViewController
public constructor(options: ViewControllerOptions) {
super(options)
this.cardVc = this.Controller('card', {
header: {
title: 'Hello, World!',
}
})
}
public render(): SkillView {
return buildSkillViewLayout('grid', {
cards: [this.cardVc.render()]
})
}
}
IDE
Coming soon...
App Lifecycle
Coming soon...
UI Design
Coming soon...
Event Handling
Coming soon...
Data Persistence
Coming soon...
Error Handling
Coming soon...
Testing
Coming soon...
User Authentication
Coming soon...
User Permissions
Coming soon...