Ich habe mir andere Antworten angesehen und bekomme immer noch diesen Fehler, wenn die Parameter fehlen. Ich vermute, es handelt sich um eine Büroklammer, aber nachdem ich die Dokumente durchsucht habe, kann ich nichts finden, was dieses Problem löst.Fehler/Fehler: click_button "Film hinzufügen" ActionController :: ParameterMissing: Parameter fehlt oder der Wert ist leer: Film
Meine Eigenschaften Spezifikation
scenario "An Admin creates a new movie" do
visit "/"
click_link "Add New Movie"```
fill_in "Title", with: "Creating first movie"
fill_in "Synopsis", with: "Lorem Ipsum"
fill_in "Year Released", with: "Date"
click_button "Add Movie"
expect(page).to have_content("Movie has been created")
expect(page.current_path).to eq(root_path)
expect(page).to have_content("Created by: #{@kyle.email}")```
end
Mein Film Modell
class Movie < ApplicationRecord
has_many :comments
belongs_to :admin
validates :title, presence: true
validates :synopsis, presence: true
validates :year_released, presence: true
has_attached_file :photo, styles: { medium: "300x200>", thumb: "100x100>" }, default_url: "/images/:style/missing.png"
validates_attachment_file_name: Foto, Spiele: [?/Png \ Z /,/jpe g \ Z /] `` `
My-Controller
def update
if @movie.update(movie_params)
flash[:success] = "Movie has been updated"
redirect_to @movie
else
flash.now[:danger] = "Movie has not been updated"
render :edit
end
end
private
def movie_params
params.require(:movie).permit(:title, :synopsis, :year_released, :photo)
end
Mein _form.html.erb
<div class="form-group">
<div class='control-label col-md-3'>
<%= f.label :photo %>
</div>
<div class='col-md-10'>
<%= f.file_field :photo, class: "btn btn-primary btn-sl pull-left" %>
</div>
<div class='form-group'>
<div class='col-md-offset-1 col-md-11'>
<%= f.submit "Add Movie", class: "btn btn-primary btn-lg pull-right" %>
</div>
Der Fehler
Failure/Error: click_button "Add Movie"
ActionController::ParameterMissing:
param is missing or the value is empty: movie```
Mein Github wenn nötig.
wie ist Ihr form_for wie – uzaif
aussehen '' '<% = form_for (@movie)%> <% = f.label: title%> <% = f.text_field: Titel, Klasse:‚Form-control ', Platzhalter:' Titel des Films ', Autofokus: true%> <% = f.label: Synopsis%> <% = f.text_area: Übersicht, Zeilen: 10, Klasse:' Formularsteuerung ', Platzhalter: 'Übersicht'%> <% = f.label: Foto%> <% = f.file_field: Foto, Klasse: "btn btn-primärer btn-sl pull-left"%> '' ' – kyle
Fehler beim Aktualisieren Film? – uzaif