README.md in fish0-0.0.4 vs README.md in fish0-0.0.5
- old
+ new
@@ -33,10 +33,11 @@
## Models
Inherit your model class from `Fish0::Model` and feel the power of the Fish!
With `attribute` define your attributes and with `primary_key` set your main primary key, e.g. `id`, `slug`, etc.
+
```ruby
# app/models/article.rb
class Article < Fish0::Model
# Define some attributes
attribute :headline, String
@@ -92,11 +93,11 @@
# app/controllers/articles_controller.rb
class ArticlesController < ApplicationController
# ...
def show
- @article = ArticleRepository.new.where(slug: params[:slug]).first!
+ @article = Article.where(slug: params[:slug]).published.first!
end
# ...
end
```
@@ -107,11 +108,11 @@
# app/controllers/articles_controller.rb
class ArticlesController < ApplicationController
include Fish0::Concerns::Paginatable
def index
- @articles = paginate(ArticleRepository.new.published)
+ @articles = paginate(Article.published)
end
# ...
protected
@@ -151,20 +152,20 @@
```ruby
# app/models/article.rb
class Article
# ...
- include Fish0::Concerns::Cacheable
+ cacheable
# ...
end
# app/controllers/articles_controller.rb
class ArticlesController < ApplicationController
# ...
def show
- @article = ArticleRepository.new.where(slug: params[:slug]).first!
+ @article = Article.where(slug: params[:slug]).first!
if stale?(@article)
respond_to do |format|
format.html
end
end