8000 Extract Rails classes into their respective files by joostvanrijn · Pull Request #50 · rubymonolith/superform · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Extract Rails classes into their respective files #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

joostvanrijn
Copy link
Contributor
@joostvanrijn joostvanrijn commented Apr 1, 2025

This might result in:

      NoMethodError - undefined method `**' for nil:

      def submit(value = submit_value, **attributes)
        input ** attributes.merge(
          name: "commit",
          type: "submit",
          value: value
        )
      end

I will look into this

# ```
#
# Now all calls to `label` will have the `text-bold` class applied to it.
class Field < Superform::Field

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be nicer to have this in a seperate file
This should be possible with zeitwerk?

'lib/superform/rails/form/field.rb'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that, but Superform::Rails::Form is already defined as a class (in this very file), so it results in a name conflict. It would take some renaming to fix that. (I'm open to suggestions).

@mvkampen
Copy link

This might result in:

      NoMethodError - undefined method `**' for nil:

      def submit(value = submit_value, **attributes)
        input ** attributes.merge(
          name: "commit",
          type: "submit",
          value: value
        )
      end

I will look into this

attributes cant be passes as nil, if you pass nil it will raise ArgumentError:
wrong number of arguments (given 2, expected 0..1) (ArgumentError)

Other suggestion:
input(name: 'commit', type: 'submit', value: value, **attributes)

But the behavior changes as you will get a SyntaxError, if you will provide the key type:, name:, or :value in attributes, as you send duplicate keywords to input.

@joostvanrijn
Copy link
Contributor Author

This might result in:

      NoMethodError - undefined method `**' for nil:

      def submit(value = submit_value, **attributes)
        input ** attributes.merge(
          name: "commit",
          type: "submit",
          value: value
        )
      end

I will look into this

There seems to be some sort of syntax error here. If I rewrite it like the following, it works just fine:

      def submit(value = submit_value, **attributes)
        input(**attributes.merge(
          name: "commit",
          type: "submit",
          value: value
        ))
      end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0