Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Igor Alexandrov
    @igor-alexandrov
    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
    it would be nice to have a macro like expose for automatically passing a variable to an operation
    7sidedmarble
    @7sidedmarble_twitter
    Also is there a mechanism for setting defaults in migrations? I don't see anything about it in the docs
    nvm I see it in the source code
    7sidedmarble
    @7sidedmarble_twitter
    I have a Array(String) field that I get validation errors on in a form
    because its not set
    but if it's not set I just want it to be []
    is there default validations turned on or something?
    Paul Smith
    @paulcsmith
    @7sidedmarble_twitter I believe that array validation but is fixed and will be in the next release!
    There is not anything to automatically pass stuff to an operation. Maybe we could add something like Rails current in the future. UT right now you need to manually pass it