Christopher Stewart

Joined

200 Experience
0 Lessons Completed
0 Questions Solved

Activity

Yup that did it! Thanks a lot. It's all working now.

I'm very close I think. At least I have the correct params coming through now.

  Parameters: {"list"=>["2"], "item"=>["5", "4", "10"]}

I just need to get the update working. It is updating positions, but multiple lists at the same time and not setting the correct list ID.

    def sort
      @items = params[:item]
      @items.each_with_index do |id, index|
        taskitem = Taskitem.where(tasklist_id: params[:list], id: id).update_all(:position => (index +1))
      end
      render :nothing => true
    end

Any thoughts on how I can change this?

Yup like Trello. I have seen some Trello clone tutorials but none that include the sortable fucntionality. That would be a great screencast!

Would I need to name the UL a unique value? Like sortable_<%= tasklist.id %>, or would checking "this" get what list I am dropping to?

Thanks Chris. I stumbled upon that tutorial and was able to get it working for one list. I am struggling trying to get it to work with multiple dynamic lists though. In my app I can create new lists when I need so I was looking to set this up to be able to drag and drop events between whatever lists that are there. Any ideas on howw to do something like that?

<% @tasklists.each do |tasklist| %>
    <ul class="sortable-list connectList agile-list" id="sortable" data-update-url="<%= sort_tasklists_url %>">
        <%= tasklist.taskitems.each do |taskitems| %>


            <li class="info-element" id="list_<%= taskitems.id %>">

          <%= taskitems.content %>

          <div class="agile-detail">

            <%= link_to "Delete", tasklist_taskitem_path(tasklist, taskitems.id), :class=>"pull-right btn btn-xs btn-    danger", method: :delete, data: { confirm: "Are you sure?" } %>
            <i class="fa fa-clock-o"></i>
            <%= taskitems.created_at.strftime('%m/%d/%Y %I:%M %p') %>
          </div>
    </li>
        <% end %>
      </ul>

Coffee script:

jQuery ->
  $("#sortable").sortable
      update: ->
      $.post($(this).data('update-url'), $(this).sortable('serialize'))

I've built a todo list that consists of lists and tasks. I am looking to use sortable to allow someone to move items around and between lists. Can anyone recommend any resources on how to do this? I would like to be able to create as many lists as I need and have them available to be dragged and dropped to. Not sure how to go about that.

So I ended up switching gears and going with the amazon S3 model. I have everything working properly so that is the good thing and it is awesome!

BUT

I have a one small issues that are puzzling me.

1.) I have a projects/show page. I am uploading multiple files for a given project off of this page. Once the file upload process is done I do not seem to see the new links to the files created until I refresh the page. I tried messing around with the uploads.js file to add in an li tage instead of an img. It does not seem to be working. I have no errros in the console either, everything looks clean. Here was my code:

     var $file = $("<li/>", {src: response.image_url});
     var $div = $("<div/>").append($file);
     $("#files").append($div);

What I am trying to output on the page for each link is:

     <li><i class="fa fa-file"></i><%= link_to (upload.file.original_filename), upload.file.url %></li>

Thanks!

EDIT: So I guess looking at this I am not really doing anything currently with the URL from the file upload. I am just using activerecord to get a list of the uploads for that project so it make sense to me now that they are not automatically showing up. So I guess I am looking how to work that in to do it as the uploads finish (just display a link to the files), or the other option would be to trigger a page refresh when all files are done uploading and leave the page code the way I have it now.

I got it! I was trying to display to file.filename instead of file.original_filename.

Thanks for your help. On to multiples now.

Thank you for you help. I'm almost there! How do I have the link_to display only the name of the file and not the whole URL of the file?

EDIT: So I think I just figured it out, but how to set the href link so it only shows the filename and not the whole file_data JSON string?

So I have been starting simple since I'm new to this. I have this working by uploading one file at a time (yay!) but I have a question on how to make an href link to the file.

I have a projects controller which has a bunch of data related to a given project. What I am looking to do is upload the file (only working on a single file at first, then I'll move on to multiple) and display a hyper link to the file on the show.html.erb page.

Looking at this:

<% if @post.file.present? %>
<%= file_tag post.file_url %>
<% end %>

How would I work that into my @project as an href link? I am getting an error that post is not definied. I tried @project but that did not work either. I have named my upload file "file" instead of image.

Great. Thanks. I saw those videos but wasn't sure if it would apply since I wouldn't be using Amazon or something like that. I'll check this one out.

I am looking to upload multiple files to local file stoarage on a server. They could be images, excell files, pdf's, .dwg etc.

Do I need to somehow declare what type of file is being uploaded or can I just sort of upload anything and store a link to it in the DB?

What would you recommend to use to do this?

I am new to rails and am not too familiar with everything yet.

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

© 2024 GoRails, LLC. All rights reserved.