Giter Club home page Giter Club logo

createdbypete.com's People

Contributors

createdbypete avatar

Watchers

 avatar  avatar  avatar

createdbypete.com's Issues

Question about an rsync destination

First thanks for the helpful guide on rsync

I have setup a sync that works pretty much. The one item that is irritating is that I have a structure in the source that includes a recursive mountpoint such as (some directories excluded:
/mnt/NAS_5TB
NAS_5TB/Acronis​
NAS_5TB/Music (this has all the media files)​
NAS_5TB/iocage​
NAS_5TB/iocage/jails​
NAS_5TB/iocage/jails/plex​
NAS_5TB/iocage/jails/plex/root​
NAS_5TB/iocage/jails/plex/root /media​
NAS_5TB/iocage/jails/plex/root/media/mountpoint back to NAS_5TB/Music
So when my rsync runs it copies not only the media directory but also copies (redundantly) all the media files again because of the mountpoint. I can put an exclude in the rsync command line but my question is: If I manually delete the redundant files from the rsync destination will it invalidate the destination? In other words will manually modifying the data in the rsync destination affect the integrity of the destination structure?

Rsync guide is great, but for one part

This part: $(date +'%Y-%m-%d') doesn't expand properly if it's in crontab.
Works great if you just escape everything: $(date +%Y-%m-%d)

Still, your guide told me almost everything I wanted to know, I just needed to figure out how to get the variables to expand.

Survey -- from a user point of view?

You have an article here: http://www.createdbypete.com/articles/working-with-nested-forms-and-a-many-to-many-association-in-rails-4/ that talks about building a survey, retrieving in a form, etc. But I've found that there seems to be a common problem in a lot of these survey demos that I hope you could help me resolve. Here goes:

Imagine a slightly different answers.html.erb file that works with just one participant (perhaps a logged in participant, which we will say is using Devise, so there is a method similar to current_participant). The new form might look something like this:

<h1><%= @survey.name %> Answers</h1>

<%= form_for(@survey) do |f| %>
  <h3><%= current_participant.name %></h3>
  <table>
    <thead>
      <tr>
        <td>Questions</td>
        <td>Answer</td>
      </tr>
    </thead>
    <tbody>
      <% @questions.each do |question| -%>
      <tr>
        <td><%= question.content %></td>
        <td>
        <%= f.fields_for :questions, question do |q| -%>
          <%= q.fields_for :answers, question.answers.find_or_initialize_by(participant: current_participant.id) do |a| -%>
            <%= a.text_area :content %>
            <%= a.hidden_field :participant_id, participant.id %>
          <% end -%>
        <% end -%>
        </td>
      </tr>
      <% end -%>
    </tbody>
  </table>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end -%>

(note the changed lines: ** q.fields_for :answers, question.answers.find_or_initialize_by(participant: current_participant.id) ** and the lack of looping through each participant)

How do we validate that the participant_id is the actual participant that is logged into the application? Since we are setting it in the form, a malicious participant could always change their hidden participant_id to be another participants id, submitting or changing an answer for another participant.

The first thought I'd have would be to modify the controllers params somewhat and merge in the participant id after the form is submitted, ala:

  def survey_params
    params.require(:survey).permit(:name,
      :questions_attributes => [:id, :content,
        :answers_attributes => [:id, :content].merge(:participant_id => current_participant.id)
      ])
  end

But merge doesn't work on nested attributes, nor do I think that would solve the problem.

Any thoughts as to what the best method to solve this would be?

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.