Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
simonovich
@simonovich
@apotonick, i mean my problems with api...
zulip works very well
Dmitrij Mukhin
@chaker05910
Hello guys , please help.
How can i render cases :
"a": {}, and "b": {"string"} ?
if i try to use property :a i received : undefined method 'a=' for ...
if: property :a do property :e end
Received undefined method 'call' for nil:NilClass
Rendering_nil = true not help...
Really don't know what to do...
Andrey Khataev
@khataev
Guys, how are you managing with fail step wich triggers rubocop's Style/SignalException and Lint/UnreachableCode ? I don't want to turn them off at all, but disabling in-place in almost every operation is boring...
Nardo Nykołyszyn
@nardonykolyszyn
What's the difference between an interactor and an operation?
Dmitriy Goncharov
@int18h

Hello, guys. Could you please help me with Reform::Form.

  class SearchForm < Reform::Form
    feature Coercion
    property :lat, virtual: true, type: Types::Nominal::Float
    property :lon, virtual: true, type: Types::Nominal::Float
    property :query_type, virtual: true, type: ::Types::Nominal::String
    property :q, virtual: true, type: Types::Nominal::String
    property :radius, virtual: true, type: Types::Nominal::Float, default: 200
  end

I set up types for properties in Form with feature Coercion. As I read from reform documentation these types are valid only during validation.
How to apply types to form fields to be sure that I can use float values (not strings by default) as values of properties.

Adam Piotrowski
@adamsarin1_gitlab
Hello @chaker05910 @khataev @nardonykolyszyn @int18h
Sorry for such a late response - we are shutting down gitter, and moving whole communication to zulipchat where we can easly organize threads and search for older content/discussions. Please ask same questions at https://trailblazer.zulipchat.com/ - you will get your answers there from someone from community or core team.
Nolan Tait
@nolantait

Anybody have good solutions for handling polymorphic collections with Reform?

I have a Resource model which belongs_to: source, polymorphic: true

I have something like:

class Form < Reform::Form
  collection(
    :resources,
    populate_if_empty: Resource,
  ) do
    property :source, form: Source::Form
  end
end

I've tried a sad hack that strips my definitions in the source form:

module Source
  module Form
    def self.new(model)
      model.class::Create::Form.new(model)
    end

    def self.definitions()
      []
    end
  end
end

But this leads to some issues with validation and prepopulating the form after errors (I lose objects that do not have a hash). Anybody have any tips for how they handle this? I'm thinking of just managing the children and errors manually myself but wanted to ask anyways

Nolan Tait
@nolantait
Sorry, just saw above too, I'll repost
ThavasipitchiahRaja
@pitchiah77_twitter
HI Need help on creating the json structure as below
{name:"servername", "rows":[
{versions:"hhhhhhhhhhhhhh"},
{versions:"hhhhhhhhhhhhhh"},
{versions:"hhhhhhhhhhhhhh"},
{versions:"hhhhhhhhhhhhhh"}
]}
can any one help me
ThavasipitchiahRaja
@pitchiah77_twitter
Hi All, Need help on creating the json structure as below
{name:"servername", "rows":[
{versions:"hhhhhhhhhhhhhh"},
{versions:"hhhhhhhhhhhhhh"},
{versions:"hhhhhhhhhhhhhh"},
{versions:"hhhhhhhhhhhhhh"}
]}
can any one help me
Kamil Milewski
@KamilMilewski
@pitchiah77_twitter
we are shutting down gitter, and moving whole communication to zulipchat where we can easly organize threads and search for older content/discussions. Please ask same questions at https://trailblazer.zulipchat.com/ - you will get your answers there from someone from community or core team.
ThavasipitchiahRaja
@pitchiah77_twitter
@KamilMilewski Thanks
Marc Seifert
@levelone
hi folks.. still fairly new to trailblazer.. does anyone know if Reform::Form supports property blocks with nested collections?
Marc Seifert
@levelone
confirmed.. this works ^
Zahidul Haque
@opodartho
Hi guys, I am getting undefined method `definitions' for NilClass:Class exception time to time from representable gem. Could it be related to threading issue? I am getting this exception around 30 minutes after staring puma
Rafael Cadenas
@cantwait
Hi guys
I have an issue with trailbrazer and slim...
Screen Shot 2020-10-27 at 9.37.12 PM.png
Rafael Cadenas
@cantwait
oh jeez Im stupid... nvm I was passing in the wrong props
the view is rendering correctly but I have a diff problem now... the element I am inserting into the view is not there
xD
Daniel
@dmtask

Hi, we have a Problem with Trailblazer and Representer. I became the following Error: NoMethodError - undefined method 'new' for Patients::BillingAddress:Module:by update a Record in my Database.

My representer Class:

class Patients::PatientInsurance::Representer::In::Default < Webapp::Representer
  resource :patient_insurances
  attributes do
    property :valid_since
  end

  has_one :billing_address, class: BillingAddress, decorator: Patients::BillingAddress::Representer::In::Default
end

Does anyone have a solution for the problem or a tip for me?

Daniel
@dmtask
Update: If I rename the class, the error will not come back. Why?
Aref Aslani
@arefaslani

Hi guys, suppose that I have a JSON like this:

{
    "sys": {
      "space": {
        "sys": {
          "type": "Link",
          "linkType": "Space",
          "id": "kk2bw5ojx476"
        }
      },
      "id": "3n2wPdC9GGi2QCdnrW4Ifz",
      "type": "Entry",
      "createdAt": "2020-04-21T13:37:24.567Z",
      "updatedAt": "2020-05-06T15:11:35.360Z",
      "environment": {
        "sys": {
          "id": "master",
          "type": "Link",
          "linkType": "Environment"
        }
      },
      "revision": 2,
      "contentType": {
        "sys": {
          "type": "Link",
          "linkType": "ContentType",
          "id": "footerSectionItem"
        }
      },
      "locale": "en-US"
    },
    "fields": {
      "title": "Germany",
      "url": "https://marleyspoon.de"
    }
  }

I've defined my representer this way:

class EntryNormalizer < Representable::Decorator
  include Representable::JSON

  nested :sys do
    nested :contentType do
      nested :sys do
        nested :id, as: :type
      end
    end
  end
end

But it doesn't work and instead raises an error that says from_hash is not defined. Do you know how can I fetch a nested property with depth more than 1?

Aref Aslani
@arefaslani
Ah no worries, sorry. I fixed it, that was just a simple mistake
Adam Piotrowski
@adamsarin1_gitlab
Hey guys, just friendly reminder that whole communication is moved to trailblazer.zulipchat.com
smriti154
@smriti154

class Payment < ApplicationRecord
belongs_to :invoice
end

module V1::Payment::Contract
class Form < Reform::Form
property :invoice_id
end
end

@form = V1::Payment::Contract::Form.new(Payment.new)
@form.validate({invoice_id: 1888888888888})
Expectation: @form.errors if invoice by this id doesn't exist

On Rails 6, with reform-rails. Could anyone please let me know, what's wrong above? validation = true, but it should be false
Adam Piotrowski
@adamsarin1_gitlab
@smriti154 we moved all communication to https://trailblazer.zulipchat.com/login/
so join us there please to get some answers :)
Akshay Birajdar
@the-spectator
@smriti154 from what I can see from the code is that validation is missing in contract class.
class NewForm < Reform::Form
  property :invoice_id
  validates :invoice_id, presence: true
end

trb_demo[dev]:015 >> new_form = NewForm.new(Payment.new)
trb_demo[dev]:016 >> new_form.validate({})
  => false
trb_demo[dev]:017 >> new_form.validate({invoice_id: 1})
  => true
trb_demo[dev]:018 >> new_form.validate({invoice_id: nil})
  => false
1 reply
Dave Myron
@contentfree
Silly question: How do I search just this channel with Gitter?
Also, can someone inform me on the proper way to specify and use a form for each item in a collection? (I tried collection :sources, form: SourceForm but my guess didn't work)
My brain and Reform never grok each other
Anyone have good reference material for using Reform without models? I'm just trying to set up some schema validation for JSON but running into brick walls.
Dave Myron
@contentfree
If I have a large JSON object that includes several nested collections that I want to validate, is it generally the case in Trailblazer that I'd create a bunch of Structs to mimic the nested objects?
I've looked into field: :hash but it doesn't seem to like combining collections and the form: option
Dave Myron
@contentfree
Oops… should be in zulip…
mr-proxyz
@mr-proxyz
Hi all!
I have Reform with a collection. How I can validate params passing in collection? I want to validate array for uniqueness. In collection populator initialize I have a :doc hash with input params, but how I can use it in dry-validation?
Ben Koshy
@benkoshy

hello friends, does the reform gem support has_many through relationships?

I have a has_many :users, through: :user_groups and would like to make it a dynamic form (with validations) - I was wondering how you all would manage this? any pointers would be much appreciated. chrs.

Ben Koshy
@benkoshy
Friends, I have an array that I want passed into a form which IS NOT backed by a model. Was wondering how you managed this?
# form object
class GroupForm < Reform::Form
  include Reform::Form::ActiveModel
  include Reform::Form::ActiveModel::FormBuilderMethods

      # doesn't seem to work
      # because there is no to_email on the active model Group object
      # was wondering how this is handled in Reform?
  collection :to_emails
end

# controller
@group = Group.new(project: @project)
@form = GroupForm.new(@group)
Josue Montano
@JosueMontano10_twitter

Hi everyone! Am new to trailblazer. I have a rails 6 app and was able to create an operation and its form. Now I want to add validation and, unfortunately it is not working. Am getting this error:

NoMethodError:
       undefined method `required' for #<Class:0x00007fa75583f8c0>
       Did you mean?  require

Am trying to use reform with dry-validation. This is my setup:

# Gemfile

gem 'rails', '~> 6.1'
gem 'trailblazer-rails', '~> 2.1.7'
gem 'reform', '~> 2.3.3'
gem 'dry-validation'
# app/concepts/subscriptions/contract/create.rb

require 'reform/form/dry'

module Subscriptions::Contract
  class Create < Reform::Form
    feature Reform::Form::Dry

    property :subscription_details
    property :user

    validation :default do
      required(:subscription_details).filled  # This is where the error is raised
    end
  end
end
# app/concepts/subscriptions/operation/create.rb

module Subscriptions::Operation
  class Create < Trailblazer::Operation
    step Model(WebPushSubscription, :new)
    step Contract::Build(constant: Subscriptions::Contract::Create)
    step Contract::Validate()
    step Contract::Persist()
  end
end
any help would be much appreciated
Viktor
@skcc321
Hi there. For those who have some memory leaks on reform + dry-validation trailblazer/reform#525
Alex Moore-Niemi
@mooreniemi
I was curious whether the project is still going, looks like news and docs peter out in 2017 and the last commit on GH is 9months ago
Ziyan Junaideen
@ziyan-junaideen

I noticed some thing in the Trailblazer home page fail Notifier::DBError within an operation. There were no hits on Google or in the Operations documentation. What would this be?

Also if I am on Rails with enable_loader = :false I assume operation naming will have to be some thing like Product::Operation::Create than Product::Create which gives a name error. That shouldn't be a problem I assume?