I already created a scafold using
rails generate scaffold myOdb2 columna:integer, columnB:string
now I want to add columnc:string
no one mentioned updating strong parameters :
So , let us say I have an existing scaffold called myapp
and I want to add more fields to that scaffold . Three things to be done .
The field to be added are :
=>
1) rails g migration add_term_count_and_current_record_count_and_previous_record_count_to_myapp term_count:integer , current_record_count:integer , previous_record_count:integer
=>
2) Update views, example updating _form.html.rb
I needed to add :
<%= f.label :current_record_count %>
<%= f.number_field :current_record_count%>
<%= f.label :current_record_count %>
<%= f.number_field :previouse_record_count%>
<%= f.label :term_count %>
<%= f.number_field :terminations_count %>
=>
3) Update Controller :
New versions of rails has what is called strong parameter to prevent hackers from passing arbitrary column field values. Long story short , update the method with the new fields names , otherwise you will not see the new fields.. they wont get passed to anywhere...untrusted values ;o)
# Never trust parameters from the scary internet, only allow the white list through.
def vendor_file_params
params.require(:vendor_file).permit(:name, :run_date, :term_count ,
:current_record_count , :previous_record_count ,:comments)
end
end