mhz
mhz

Reputation: 1029

ActiveAdmin Edit inputs missing attribute

For some reason my "Edit" page for one of my model (chart.rb) is missing on of it's attributes.

Simply adding

form do |f|
    f.semantic_errors
    f.inputs
    f.actions
end

to the chart.rb file will miss my attribute called type.

If I add a special field for type like so

form do |f|
    f.semantic_errors
    f.inputs
    inputs 'test' do
      input :type
    end
    f.actions
end

It would properly render the type input in a nice format at another section below.

Does anyone know why f.inputs might be missing one of my Model attributes?

quick EDIT: I did a quick patch fix with the following code:

form do |f|
    f.semantic_errors
    f.inputs do
      f.input :project
      f.input :name
      f.input :type
      f.input :y_axis
      f.input :y_max
      f.input :y_min
      f.input :x_axis
      f.input :x_max
      f.input :x_min 
    end
    f.actions
  end

Which rendered the form just fine. But when trying to save it, I got the following error in Rails:

The single-table inheritance mechanism failed to locate the subclass: 'graph'. This error is raised because the column 'type' is reserved for storing the class in case of inheritance. Please rename this column if you didn't intend it to be used for storing the inheritance class or overwrite Chart.inheritance_column to use another column for that information.

Looks like the column name type is reserved? Is this an ActiveAdmin reservation? Hm.....

Upvotes: 1

Views: 1112

Answers (1)

Mohamed Ziata
Mohamed Ziata

Reputation: 1226

type is a reserved word for rails.

Here u can see all the reserved word

I recomend you change the column type for kind or an other word.


And you need to add f. to inputs, like so:

form do |f|
  f.semantic_errors
  f.inputs
  f.inputs 'test' do
    input :type
  end
  f.actions
end

Upvotes: 4

Related Questions