Displaying Read-Only Attribute #175
firewalker06
started this conversation in
General
Replies: 2 comments
-
Or a |
Beta Was this translation helpful? Give feedback.
0 replies
-
We could probably check for class Post < ActiveRecord::Base
attr_readonly :title
end
post = Post.create!(title: "Introducing Ruby on Rails!")
post.update(title: "a different title") # change to title will be ignored https://api.rubyonrails.org/classes/ActiveRecord/ReadonlyAttributes/ClassMethods.html |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Since madmin works by iterating through
model.attributes
, I was thinking usingActiveModel::Attributes::ClassMethods#attribute
would work if we want to have a Read-Only attribute in madmin. Turns out its true:But I think it would be good idea to have
read_attribute
that displays in Index and Show view.Beta Was this translation helpful? Give feedback.
All reactions