Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Jeremy Woertink
    @jwoertink
    Well, if it doesn't then I feel like it should :sweat_smile:
    I can't really go off what my apps do because my apps are not standard lucky
    let me see what the website does though...
    7sidedmarble
    @7sidedmarble_twitter
    yeah maybe its a me thing but I dont think it does that
    Jeremy Woertink
    @jwoertink
    nevermind... I can't boot the website lol
    Wout
    @wout
    @7sidedmarble_twitter Mine do refresh after compilation.
    7sidedmarble
    @7sidedmarble_twitter
    weird, I wonder what's different for me
    Wout
    @wout
    But sometimes the browsersync connection fails for some reason, which can be fixed with a manual reload.
    Yeah, that's odd. I've got four Lucky apps now and they all do it.
    Jeremy Woertink
    @jwoertink
    that's where we call it. After you update a crystal file, it will call that to relaunch browser sync if it's not running, or it will just tell it to reload
    Check that browsersync is running on the correct port. Also, is your lucky app running on a standard port? Maybe it's a bug related to that?
    7sidedmarble
    @7sidedmarble_twitter
    let me check that out
    Jeremy Woertink
    @jwoertink
    If you happen to find an issue, please report so we can keep track of it
    7sidedmarble
    @7sidedmarble_twitter
    I'm also doing some crazy stuff with docker so that could explain it too.
    Håkan Nylén
    @confact
    My browsersync haven't worked either. But I just refresh manually. Tired to fix small things in my dev env :D
    btw @jwoertink - how you feel about luckyframework/avram#392 ? - Is it unnecessary or a good idea?
    Jeremy Woertink
    @jwoertink
    taking a look
    7sidedmarble
    @7sidedmarble_twitter
    Yeah I wasn't using a docker setup before and it was not working there
    it worked for JS and CSS but nothing else
    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