I have an issue when submitting a form.

I have two models, `:service` and `:booking`. For a service, there is a button:

```
<%= link_to "Book Now", new_booking_path(service_id: @service.id) %>

```

When this button is clicked it takes the user to the `_form.html.erb` where they can book the service. This is the simplified booking form:

```
<%= simple_form_for (@booking) do |f| %>

    <%= f.label "Booking Date" %><br>
    <%= f.text_field :date %>
    <%= f.text_field :time, :id => "timepicker" %>
    <%= f.input :address, label: "Address" %>
    <%= f.input :postcode, label: "Postcode" %>
    <%= f.input :suburb, label: "Suburb" %>

    <%= f.input :servicetitle, :input_html => { :value => @service.title } %>
    <%= f.input :serviceprice, :input_html => { :value => @service.price } %>
    <%= f.input :servicetime, :input_html =>  { :value => @service.time } %>

    <%= f.button :submit %>
<% end %>

```

As you can see, I have three fields, `:servicetitle`, `:serviceprice` and `:servicetime`. 

These fields get their input values from the `@service.id` value passed through the link\_to button. I am able to access the records like `@service.title` using this instance variable in the `bookings_controller`:

```
@service = Service.find_by_id(params[:service_id])

```

The problem I am having is that if one of the field validation fails (say the `:date` field), then the user gets redirected back to the `_form.html.erb` and I get the error

> 
> NoMethodError in Bookings#create
>    
> 
>  undefined method `title`
> 
> 
> 

I would also get the errors:

> 
> undefined method `price`
> 
> 
> 

and:

> 
> undefined method `time`
> 
> 
> 

I think this is because Rails doesn't have access to the `@service` instance variable anymore?

How am I able to fix this when a validation fails?

**Edit**:

Create method in bookings controller:

```
def create
    @booking = current_user.bookings.build(bookings_params)
    if @booking.save
        BookingMailer.form_confirmation(@booking).deliver
        redirect_to @booking
    else
        render 'new'
    end
end

```