For 1) Use enum default field in your migration for User like this
t.column :role, :string, default: "corporate" or use https://github.com/FooBarWidget/default_value_for For 2) Roles were stored as string and your collection contains symbols . :corporate != "corporate" Try this f.input :role, as: :radio, collection: User.roles.except(:free).collect{|x| [x.to_s, x.to_s]} On Sat, Nov 29, 2014 at 6:03 PM, Sumit Sharma <[email protected] > wrote: > I need to check radio button in active admin form > I've a User model and in that I've a attribute for user's role. and for > the list of roles I've created a enum. > > In my model : > enum role: [:corporate, :demo, :free] > > my new or edit form : > form do |f| > f.inputs "Users" do > f.input :email > f.input :password > f.input :role, as: :radio, collection: User.roles.except(:free) > end > f.actions > end > > when I create a new user and select a role and save, then I can save the > role with the user. but when I come to edit page i didn't see the related > role radio button as checked. > I need to do the two things > 1) on new page show first radio button as checked > 2) on edit page checked the radio button of user's role > > May be this very silly question, but I don't know how to do it and didn't > find any solution. > > Please help and Thanks in advance! > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/8b1cb268-4f83-4f2b-aa5a-916a98d45532%40googlegroups.com > <https://groups.google.com/d/msgid/rubyonrails-talk/8b1cb268-4f83-4f2b-aa5a-916a98d45532%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAFKVRj_-WE%3DJOo0TFj325JCKtVc%3DaCSHt6jv%3DWm65%2B%3DEz%2BTw9A%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

