I have created a simple form, the user click on three items and press submit and an email is being send, all of this works. However, when i test it and check the show page, it doesn't show any entered details which were selected by the user, just a blank page.i don't receive any errors.
controller
class PositionsController < ApplicationController
def new
@position = Position.new
end
def show
@position = Position.find(params[:id])
end
def create
@position = Position.new(position_params)
if @position.save
PositionMailer.general_message(@position).deliver
else
render :new
end
end
private def position_params
params.permit(:date, :time, :activity)
end
end
view
<div class="form">
<%= simple_form_for @position do |f| %>
<div class= "trip">
<div class="trip-text">
Trip number
</div>
<div class="trip-field">
<%= f.input :tripnumber, label: false, placeholder: 'enter here' %>
</div>
</div>
<div class= "activity">
<div class="activity-text">
Activity
</div>
<div class="activity-field">
<%= f.input :activity, label: false, collection: [['Sailing to loadport, expected arrival', 'Sailing to loadport, expected arrival'], ['Sailing to discharge port, expected arrival', 'Sailing to discharge port, expected arrival'],
['Loading untill', 'Loading untill'], ['Discharging untill', 'Discharging untill'], ['Waiting for loading, expect to start', 'Waiting for loading, expect to start'], ['Waiting for discharge, expect to start', 'Waiting for discharge, expect to start']] %>
</div>
</div>
<div class="date">
<div class="date-text">
Date
</div>
<div class="date-field">
<%= f.date_field :date, class: 'form-control' %>
</div>
</div>
<div class="time">
<div class="time-text">
Time
</div>
<div class="time-field">
<%= f.time_field :time, value: "%H:%M", min: 'hh:mm:ss', max: 'hh:mm:ss' %>
</div>
</div>
<%= f.submit "Send update", class: "submit"%>
</div>
Since i have no error and all works fine except i dont have the input of the users i dont know where to look, i looked in the forum and on google but no succes
In create
action, add redirect_to @position
if @position.save
PositionMailer.general_message(@position).deliver
redirect_to @position
else
render :new
end
Hope that helps!
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments