When i display the form, i type in some stuff then i want it to take to the index view
_form.html.erb
<%= simple_form_for @series, :url => { :action => :new } do |f| %>
<%= f.input :title, label: "Series Title" %>
<%= f.input :description %>
<%= f.input :actor %>
<%= f.button :submit %>
<% end %>
Can some one please help me indentify the error for me, i dont know why its not creating the tv series i try to create, when i check tvseries.connection, it says its nil, there isnt anything in.
tv_series_controller.rb
class TvSeriesController < ApplicationController
def index
end
def new
@series = Series.new
end
def create
@series = Series.new(serie_params)
if @series.save
redirect_to root_path
else
render 'new'
end
end
private
def show
params.require(:series).permit(:title, :description,:actor)
end
end
newhtml.erb
<h1>New Serie</h1>
<%= render 'form' %>
routes.rb
Rails.application.routes.draw do
resources :tv_series
root 'tv_series#index'
end
_create_series.rb
class CreateSeries < ActiveRecord::Migration
def change
create_table :series do |t|
t.string :title
t.text :description
t.string :actor
t.timestamps null: false
end
end
end
Aucun commentaire:
Enregistrer un commentaire