Giter VIP home page Giter VIP logo

feedback's Introduction

Hi there 👋.

Current is the future.

Utilities

feedback's People

Contributors

arlyxiao avatar ben7th avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

ben7th

feedback's Issues

重构了几个地方

第一个问题,已改完

措词一定要统一,方便大家沟通,和理解
比如 problem_reposts 中文统一用 ‘问题’ 这个词,不要一个页面用 ‘问题’ 这个词,另一个页面用 ‘报告’ 这个词

第二个问题,已改完

ProblemReportsController 的 index 方法,抽取成多个小方法

第三个问题,已改完

ProblemReportsController 的 create 方法中

@problem_report 先 create 又 save,这样不好,完全可以只 save 一次

第四个问题,已改完

用户提交反馈的表单中(/problem_reports/new.html.haml)

  %input{:type=>'hidden',:value => field.id, :name=>"problem_report[problem_field_data_attributes][#{field.id}][problem_field_id]"}

  %input{:type=>'text', :name=>"problem_field_data[#{field.id}]"}

改为

%input{:type=>'hidden',:value => field.id, :name=>"problem_report[problem_field_data_attributes][#{field.id}][problem_field_id]"}

%input{:type=>'text', :name=>"problem_report[problem_field_data_attributes][#{field.id}][content]"}

这样修改后,rails 可以把 problem_field_datas 的数据完全拼装好,下边的内容就可以省去了

@problem_report.problem_field_data.each do |field_data|
    field_data.content = params[:problem_field_data][field_data.problem_field_id.to_s]
    field_data.save
end

第五个问题,已改完

创建 problem_reports 时的 attachement 关联移动到 problem_reports 模型的 after_create 上
遵守 逻辑尽量封装到模型上 的原则

  attr_accessor :attachement_ids

  after_create :set_attachements
  def set_attachements
    unless self.attachement_ids.blank?
      self.attachement_ids.each do |attachement_id|
        problem_report_attachement = ProblemReportAttachement.find(attachement_id)
        problem_report_attachement.problem_report = self
        problem_report_attachement.creator = self.creator
        problem_report_attachement.save
      end

      # 生成 zip 包
      # self.build_attachements_zip(self.creator)
    end
  end

第六个问题,还未修改

目前附件上传没有成功保存文件,只是单纯的创建了 problem_report_attachement 数据库条目

第七个问题,还未修改

接第六个问题,problem_reports after_create :set_attachements 中 生成ZIP包的逻辑已经注释掉,需要
修正第六个问题后,在解除注释

已提交到 https://github.com/ben7th/feedback
需要pull 一下代码

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.