-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
class Avo::Resources::Movie < Avo::Resources::ArrayResource | ||
def records | ||
[ | ||
{ | ||
id: 1, | ||
name: "The Shawshank Redemption", | ||
release_date: "1994-09-23" | ||
}, | ||
{ | ||
id: 2, | ||
name: "The Godfather", | ||
release_date: "1972-03-24", | ||
fun_fact: "The iconic cat in the opening scene was a stray found by director Francis Ford Coppola on the studio lot." | ||
}, | ||
{ | ||
id: 3, | ||
name: "Pulp Fiction", | ||
release_date: "1994-10-14" | ||
} | ||
] | ||
end | ||
|
||
def fields | ||
main_panel do | ||
field :id, as: :id | ||
field :name, as: :text | ||
field :release_date, as: :date | ||
field :fun_fact, only_on: :index, visible: -> { resource.record.fun_fact.present? } do | ||
record.fun_fact.truncate_words(10) | ||
end | ||
|
||
sidebar do | ||
field :fun_fact do | ||
record.fun_fact || "There is no register of a fun fact for #{record.name}" | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# This controller has been generated to enable Rails' resource routes. | ||
# More information on https://docs.avohq.io/3.0/controllers.html | ||
class Avo::MoviesController < Avo::ArrayController | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters