I'm creating a ticket booking app for my sample project using Ruby on Rails 4.1. Three are three models - Events, Tickets and Bookings. Events have many tickets and bookings. Tickets have many bookings and they belong to events. Bookings belongs to events and tickets.

Here's the ticket model:

```
class Ticket < ActiveRecord::Base
 belongs_to :event
 has_many :bookings

 before_create :check_start_date
 before_update :check_start_date

def self.check_start_date
 if self.booking_start_date == Date.today
    self.update_attribute(:status => 'Open')
end
end

```

The ticket controller:

```
 class TicketsController < ApplicationController

def index
    @event = Event.find(params[:event_id])
    @tickets = @event.tickets.all
end

def show
    @event = Event.find(params[:event_id])
    @ticket = @event.tickets.find(params[:id])
end

def new
    @event = Event.find(params[:event_id])
    @ticket = Ticket.new
end

def create
    @event = Event.find(params[:event_id])
    @ticket = @event.tickets.create(ticket_params)
    if @ticket.save
        redirect_to [@event, @ticket]
    else
        render 'new'
    end
end

def edit
    @event = Event.find(params[:event_id])
    @ticket= @event.tickets.find(params[:id])
end

def update
    @event = Event.find(params[:event_id])
    @ticket = @event.tickets.find(params[:id])

    if @ticket.update(ticket_params)
        redirect_to [@event, @ticket]
    else
        render 'edit'
    end
end

def destroy
    @event = Event.find(params[:event_id])
    @ticket = @event.tickets.find(params[:id])
    @ticket.destroy
    redirect_to event_tickets_path
end

private

def ticket_params
    params.require(:ticket).permit(:ticket_name, :booking_start_date, :booking_end_date, :ticket_price, :ticket_quantity, :minimum_quantity, :maximum_quantity, :terms_conditions, :more_information, :status)
end

```

end

The form partial:

```
<%= form_for ([@event, @ticket]) do |f| %>
        <%= f.label :ticket_name %>
        <%= f.text_field :ticket_name %>

        <%= f.label :booking_start_date %>
        <%= f.datetime_select :booking_start_date %>

        <%= f.label :booking_end_date %>
        <%= f.datetime_select :booking_end_date %>

        <%= f.label :ticket_price %>
        <%= f.text_field :ticket_price %>

        <%= f.label :ticket_quantity %>
        <%= f.text_field :ticket_quantity %>

        <%= f.label :minimum_quantity %>
        <%= f.text_field :minimum_quantity %>

        <%= f.label :maximum_quantity %>
        <%= f.text_field :maximum_quantity %>

        <%= f.label :terms_contitions %>
        <%= f.text_area :terms_conditions %>

        <%= f.label :more_information %>
        <%= f.text_area :more_information %>
        <%= f.hidden_field :status %>
        <%= f.submit 'Create Ticket' %>

```

I use a hidden field for :status in the form partial and I'm trying to update the value to open or closed based on the model method check\_start\_date. But, I'm not able to create or update tickets and I get a No Method Error in Tickets Controller, undefined method `check\_start\_date'. 

Where am I going wrong? Is using a hidden field and a model method to update it's status the right way to do this?