Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    7sidedmarble
    @7sidedmarble_twitter
    But right now I'm still testing to make sure it's not just my setup
    Ghost
    @ghost~56ba344de610378809c0a277
    FYI, I had to add reloadDelay: 500 to my bs-config.js to make everything reload automatically
    otherwise i needed to refresh manually
    7sidedmarble
    @7sidedmarble_twitter
    ahh, think it was timing out?
    Ghost
    @ghost~56ba344de610378809c0a277
    something like that, i took a look at the watch file but couldn’t fix my issue, reloadDelay did the trick
    Ghost
    @ghost~5ebdf6e0d73408ce4fe3cef5
    How can I tell whether my Avram::SaveOperation is a create or an update?
    Paul Smith
    @paulcsmith
    You can check for record using: @record.nil?
    If it’s nil it is a create. I think there are methods that do that so you don’t need to use the instance variable but I don’t remember them off the top of my head
    Igor Alexandrov
    @igor-alexandrov
    I added enctype: "multipart/form-data" to form_for to be able to upload a file and now I am getting
    web          | POST /images
    web          |  ▸ Handled by Images::Create
    web          |  ▸  Lucky::MissingNestedParamError
    web          |
    web          |      Missing param key: 'image'
    web          |
    web          |     Backtrace
    web          |
    web          |      lib/lucky/src/lucky/params.cr:168:7 in 'nested'
    web          |      src/models/image.cr:12:3 in 'permitted_params'
    And another question is there a way to add parameters logging in development in each request?
    Håkan Nylén
    @confact
    @igor-alexandrov i think you can use before or after hooks in a parent action for logs
    For temporary debugging at least
    Jeremy Woertink
    @jwoertink
    @igor-alexandrov it almost looks like your operation is looking for the param image:image. I'd suggest trying what @confact said with a hook and log out your params to see if they're being passed how you'd expect
    Also note that our current file uploading handling is a bit wonky and could use some love. luckyframework/lucky#1147 luckyframework/lucky#1145
    There might be other issues, but those were the ones off the top of my head I could think of. So if you do notice there's a bug, let us know!
    Igor Alexandrov
    @igor-alexandrov
    @jwoertink file uploading is what I am trying to solve by integration Shrine to Lucky
    Jeremy Woertink
    @jwoertink
    noice!
    :heart:
    Igor Alexandrov
    @igor-alexandrov
    Going back to my last error, strange that this does not happen without enctype: "multipart/form-data" passed to form_for
    Ghost
    @ghost~5ebdf6e0d73408ce4fe3cef5
    @paulcsmith There is a record method and that works. Thank you.
    Igor Alexandrov
    @igor-alexandrov
    Ok, @paulcsmith @jwoertink I understood what happens. My form has only one param asset and it is send in multipart, not in form data. Operation looks only yo form data, and if it cannot find required param key, exception is raised. I fixed the problem aboce by adding another field to the form – a text field.
    Jeremy Woertink
    @jwoertink
    Glad you got it figured out. Is there an issue we need to fix on our end? Or you think it's good now?
    Igor Alexandrov
    @igor-alexandrov
    Yes, I believe this is an issue
    You can reproduce this by creating an Operation that accepts only one attribute and it is from multipart.
    Igor Alexandrov
    @igor-alexandrov
    class SaveImage < Image::SaveOperation
      param_key :image
    
      attribute asset : Lucky::UploadedFile
      attribute title : String
    
      before_save :assign_asset
    
      def assign_asset
        pp! asset.inspect
      end
    end
    What type should I specify for uploaded files in Operations? Using Lucky::UploadedFile raises an error
    web          | In src/operations/save_image.cr:9:21
    web          |
    web          |  9 | attribute asset : Lucky::UploadedFile
    web          |                        ^
    web          | Error: undefined constant Lucky::UploadedFile::Lucky
    David Roetzel
    @oneiros
    This error is about the missing nested Lucky module that avram adds to all supported data types. Here is the example for String: https://github.com/luckyframework/avram/blob/master/src/avram/charms/string_extensions.cr
    Lucky::UploadedFile will probably need something similar.
    Igor Alexandrov
    @igor-alexandrov
    Ok, this is a good starting point, thanks
    Didde Brockman
    @diddeb

    Holy cow, I am so lost looking for the support (or suggested pattern) to do nested model creation by means of JSON posts...

    {
      "parent": {
        "name": "Parent",
        "children": [
          {
            "name": "Child 1"
          },
          {
            "name": "Child 2"
          }
        ]
      }
    }

    ...for example. Any clues?

    Jeremy Woertink
    @jwoertink
    @diddeb I'm not sure that I follow.... Do you mean you want to take a json example like that, pass it to some function and have it save multiple models at the same time?
    1 reply
    Paul Smith
    @paulcsmith
    @diddeb Unfortunately this is quite tricky in Lucky right now. I've got an issue I'm working on to make this super easy. I'm trying to find some gists of how people did it, but the gist is that you'd probably want to manually parse the JSON and save operations as you go. For example: https://gist.github.com/paulcsmith/6d71e7a1557f7456bb5c3f8ed0c4f645
    1 reply
    Basically it lets you operate on the raw JSON. Also see https://crystal-lang.org/api/0.35.0/JSON/Any.html for how to traverse and use JSON::Any. Let us know if you run into anything with that. I'll try to help the best I can :D
    1 reply
    Håkan Nylén
    @confact
    I am so sad, someone I look up to in the privacy website analytics group of projects is accusing me of ripping their product off :(
    Matthew McGarvey
    @matthewmcgarvey
    Sorry about that! I'm sure you ripped off their product in the same way that they ripped off the product they were inspired by. I find it hard to think like that at times as well
    Jeremy Woertink
    @jwoertink
    Send them a picture of Coke and another one of Pepsi
    Wout
    @wout
    @confact Ignore them. No one starts from a blank slate, everybody copies to some extent. And with so much software around, you'll always have people feeling other products are too similar to theirs.

    Good artists copy; great artists steal.

    - Picasso

    Håkan Nylén
    @confact
    Wasn't that Steve Jobs? ;)
    Wout
    @wout
    Another example of copying. 😂️
    Håkan Nylén
    @confact
    Yea I know, but It is really I guy I look up to and I listen to their podcast. They and another service inspired me to do my own.
    Jeremy Woertink
    @jwoertink
    y'all don't even realize what's coming.... this next release is gonna be :fire:
    9 replies
    Matthew McGarvey
    @matthewmcgarvey
    fire
    Wout
    @wout
    😂️
    Jeremy Woertink
    @jwoertink
    exactly like that
    Igor Alexandrov
    @igor-alexandrov
    I missed all day migration from a DataStore to PG on GCP. Hope tomorrow I will have time to take a look at Shrine <=> Lucky adapter.
    7sidedmarble
    @7sidedmarble_twitter
    Is there a conveinant shorthand to pass a variable like current_user into a bunch of different actions?
    Like expose, but for actions
    sorry
    not actions
    operations