How to add a virtual attribute to a model in Ruby on Rails?

Ruby actually lets you create virtual attributes this way, which keeps you from having to manually create getter and setter methods: attr_reader :palindrome #getter attr_writer :palindrome #setter attr_accessor :palindrome #both You can also pass multiple arguments too: attr_accessor :palindrome, :foo, :bar The documentation for it isn’t the greatest.

How to display only the value in edit page in Active Admin

As Alex said, set to disabled. You could then use css to get the visual you wanted, if you can live with the semantics of that. The syntax was slightly different for me to get this to work. in your admin form: f.input :finish_position, input_html: { disabled: true } in your CSS active_admin.css input[disabled=”disabled”], input[disabled] … Read more

How to Properly Configure Rails 4.1 Enums in ActiveAdmin

Building off of Jack’s answer, here’s what worked for me. Say your ActiveRecord model is Tweets: f.input :privacy_level, as: :select, collection: Tweet.privacy_levels.keys Key things to note here: your ActiveRecord has a useful dictionary (available at enum_name.pluralize) of enum keys to values. using strings (and ignoring the underlying integer representation) makes it easier to write to … Read more

File upload with Activeadmin Rails using paperclip

I found a way to use Paperclip with Active Admin. I added this code in my model “Event” : has_attached_file :map, :styles => { :medium => “238×238>”, :thumb => “100×100>” } And i did this for my admin model : ActiveAdmin.register Event do form :html => { :enctype => “multipart/form-data” } do |f| f.inputs “Details” … Read more