iam new to rails, i have model(welcome) and i want to update the model with single form where the form has duplicate fields . only second field updates the model ..
routes
get 'welcome/index'
get 'welcome/new'
post 'welcome/create'
root 'welcome#index'
class WelcomeController < ApplicationController
def index
end
def new
@article = Welcome.new
end
def create
@article = Welcome.new(user_params)
if @article.save
redirect_to welcome_new_path
else
render 'new'
end
end
private
def user_params
params.require(:welcome).permit(:name , :descrip )
end
end
<%= form_for@ article, url: welcome_create_path do |f | %>
<%= f.text_field: name %>
<%= f.text_field: descrip %>
<%= f.text_field: name %>
<%= f.text_field: descrip %>
<%= f.submit "Create" %>
<% end %>
Aucun commentaire:
Enregistrer un commentaire