README.md in rollerskates-0.1.0 vs README.md in rollerskates-0.1.1
- old
+ new
@@ -34,11 +34,11 @@
| └───views
└───config
| └─── routes.rb
| └───application.rb
└───db
-| └───development.sqlite3
+| └───app.db
└───config.ru
```
### Application.rb
Set up your application this way:
@@ -55,14 +55,17 @@
### Config.ru
Set up your routes this way:
```ruby
-require "/config/application.rb"
+APP_ROOT = __dir__
+require_relative "./config/application.rb"
TodoApplication = Todolist::Application.new
+use Rack::Reloader, 0
use Rack::MethodOverride
-require "/config/routes.rb"
+require_relative "./config/routes.rb"
+use Rack::Static, urls: ["/css", "/js", "/fonts"], root: "/app/assets"
run TodoApplication
```
### Routes
@@ -102,24 +105,48 @@
class Item < Rollerskates::BaseRecord
property :name, type: :text, nullable: false
property :status, type: :boolean, nullable: false
create_table
+ belongs_to :user
+ has_many :product
+
+ def self.recent
+ order("id DESC").limit(5)
+ end
end
```
Rolletskates automatically adds the `id, created_at and updated_at` fields and thus need not to be specified in the model. Other properties, however should be specified as above.
+You can make use of associations with the rollerskates framework. Also, you can chain methods to a degree. Rollerskates ORM can accommodate chaining such as:
+> `select(:prop1, :prop2, :prop3)`
+>
+> `where(prop2: "Value")`
+>
+> `order("prop DESC")`
+>
+> `limit(5)`
+
+And combinations such as:
+> `select(:id, :name).where(status: "active").limit(5)`
+
+NB: Unlike Rails, `Rollerskates` uses sigular expression for both `has_many` and `belongs_to`
+
### Views
```
│
└───views
| └───items
| |____ new.erb
| |____ show.erb
+|───────layouts
+| |____ application.erb
```
-Files in the view folder should be organized according to the controller and action name.
+Files in the view folder should be organized according to the controller and action name. Instance variables declared in the respective controller action are available to your view.
+
+The views make use of a layouts. You can abstract common elements in all your views to the `views/layouts/application.erb` file.
## Testing
The tests could be run automatically by using
```bash