dfasofjoaishoiqw4e
dfasofjoaishoiqw4e

Reputation: 77

Rails input form boolean

I got problem with make form where i can chose between true or false.
In model ticket i got:
type:boolean

When i'm making check_box in form i got this error msg:

Invalid single-table inheritance type: 1 is not a subclass of Ticket

My form code:
<%= form_for [@movie, @seance, @ticket] do |f| %>
<div>
<%= f.label :type %>
<%= f.check_box :type %>
<%end%>

Upvotes: 1

Views: 2592

Answers (2)

odraude7
odraude7

Reputation: 11

You can change the Single Table Inheritance 'type' column, changing the name for something else.

self.inheritance_column = :fake_column

https://devblast.com/b/single-table-inheritance-with-rails-4-part-1

Upvotes: 0

SteveTurczyn
SteveTurczyn

Reputation: 36870

type is a reserved word in ruby-on-rails, used for STI.

Change your column name to, say, :ticket_type

Upvotes: 3

Related Questions