Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8811493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:22:45+00:00 2026-06-14T03:22:45+00:00

In my models, BookHeader has many Category So, when edit or create new BookHeader,

  • 0

In my models, BookHeader has many Category
So, when edit or create new BookHeader, the form show like this
Enum fix?

I wanna change the “category #{id}” to category name by define a category_enum method but it still don’t work. Please help!

Code for BookHeader model

class BookHeader < ActiveRecord::Base
  attr_accessible :autho, :category_id, :description, :title, :book_type, :year,:publisher_id,:detail
  has_many :books
  belongs_to :category
  belongs_to :publisher
  TYPE = {:ebook=>"Ebook",:paper_book=> "PaperBook",:magazine=> "Magazine",:media=> "Media"}
  DEFAULT_TAB = :paper_book
  BOOKS_PER_PAGE = 1 # books to show in a pages (pagination)
  extend FriendlyId
  def book_type_enum #it worked here
    TYPE.map{|key, val| [val]}
  end
  def category_enum #but dont' work here
    ["a","b"]
  end

Code for edit form

edit do
        field :title
        field :description, :text do
          ckeditor do true end
        end
        field :autho
        field :book_type
        field :category
      end

See the Division attribute in this link

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:22:47+00:00Added an answer on June 14, 2026 at 3:22 am
    alias_attribute :name, :you_field_you_want_to_display
    

    I think it’s more flexible way, there is no need to rename something and everything will work properly

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My models I'm trying to create a form for an Annotation . This annotation
The models I'm working with look like this: class ComplexAssertion < ActiveRecord::Base has_many :expression_groups
My models looks something like this (stripped down to the bare minimum for this
In models and controllers, we often use Rails macros like before_validation , skip_before_filter on
My models are set up as follows (this is an example and not my
Models is populated within the ctor. When I click Edit to edit an item
models.FloatField creates a double in MySQL. Is it possible, and how, to create a
models.py class Category(models.Model): name = models.CharField(max_length=50) class SubCatergory(models.Model): parent_category = models.ForeignKey(Category) name = models.CharField(max_length=100)
models.py class Category(models.Model): name = models.CharField(max_length=200) slug = models.SlugField() parent = models.ForeignKey('self', blank=True, null=True,
Models: User has_many Categories, has_many Entries Category has_many Entries Entry belongs_to both Category and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.