Skip to content

Commit efed854

Browse files
authored
added documentation on how to set attributes to invisible in different views (excid3#151)
1 parent 8f29bfd commit efed854

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,23 @@ rails g madmin:views:index
7373
# -> app/views/madmin/application/index.html.erb
7474
```
7575

76+
You might want to make some of your model's attributes visible in some views but invisible in others.
77+
The `attribute` method in model_resource.rb gives you that flexibility.
78+
79+
```bash
80+
# -> app/madmin/resources/book_resource.rb
81+
```
82+
```ruby
83+
class UserResource < Madmin::Resource
84+
attribute :id, form: false
85+
attribute :tile
86+
attribute :subtitle, index: false
87+
attribute :author
88+
attribute :genre
89+
attribute :pages, show: false
90+
end
91+
```
92+
7693
You can also scope the copied view(s) to a specific Resource/Model:
7794
```bash
7895
rails generate madmin:views:index Book

0 commit comments

Comments
 (0)