I am building a job app with Rails. In my job 'new' page. I have a preview functionality where a user can click a 'preview button' to see how the job would look like when posted. The preview page opens in another tab. The user is then supposed to return back to the job 'new' page, to either post the job or make edits.
The main issue is that, after I click on the preview button and the new tab opens, both the 'preview' and 'post job' button on the job 'new' page become disabled and and I cant click on 'post' to save the job to the database. This is my controller 'create method'
def create
@job = Job.new(job_params)
if params[:previewButt] == "Preview"
flash[:alert] = "This is a PREVIEW of your job posting. Go back to the previous tab to Post the job or make edits."
render :create
elsif
params[:createButt] == "Post Job"
@job.save
redirect_to root_path
else
render :new
end
end
In my job 'new' page, these are the two buttons i have,
<div class="col-md-9 text-center" style="margin-top: 110px;">
<%= f.button :submit , name: "previewButt", value: "Preview",
formtarget:"_blank" %>
<%= f.button :submit , name: "createButt", value: "Post Job", class:
"btn btn-success post-btn" %>
</div>
I need to make sure that, the two buttons are still able to function even after a user clicks on preview button.
Aucun commentaire:
Enregistrer un commentaire