cant seem to update my values in ruby -
so have form color palette update live, i've been stuck problem days.
this controller update
def update @project = project.find_by(id: params[:id]) binding.pry @palette = @project.palette unless @project render json: {error: "project not found"}, status: 404 return end @project.update(project_params) @project.update_palette(palette_params) render json: project end
one project has 1 palette
private def project_params params.require(:project).permit(:name, :option, :id, :background_dark_color, :background_light_color, :dark_color1, :dark_color2, :light_color1, :light_color2) end def palette_params params.require(:palette).permit(:background_dark_color, :background_light_color, :dark_color1, :dark_color2, :light_color1, :light_color2) #=> [ :id, :name, :_destroy ]) end
the error throwing me enter image description here
added form
<%= palette.label 'background_dark_color' %>: <%= palette.text_field :background_dark_color, maxlength: 6, placeholder: "#{@project.palette}" %><br/> <%= palette.label 'background_light_color' %>: <%= palette.text_field :background_light_color, maxlength: 6, placeholder: "#{@project.palette}" %><br/> <%= palette.label 'dark_color1' %>: <%= palette.text_field :dark_color1, maxlength: 6, placeholder: "#{}" %><br/> <%= palette.label 'dark_color2' %>: <%= palette.text_field :dark_color2, maxlength: 6, placeholder: "#{@project.palette}" %><br/> <%= palette.label 'light_color1' %>: <%= palette.text_field :light_color1, maxlength: 6, placeholder: "#{@project.palette}" %><br/> <%= palette.label 'light_color2' %>: <%= palette.text_field :light_color2, maxlength: 6, placeholder: "#{@project.palette}" %><br/> <%= palette.submit %> <%= link_to 'destroy', project, method: :delete %> <!-- , data: { confirm: 'are sure?' } confirm message , sucks, better use "undo" --> <% end %>
Comments
Post a Comment