Skip to content

Raise when options_for_select is used as a value #293

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

joeldrapper
Copy link
Collaborator

No description provided.

@joeldrapper joeldrapper marked this pull request as ready for review May 8, 2025 11:14

def select_tag(name, *, **, &block)
output = if block
view_context.select_tag(name, capture(&block), *, **)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This actually differs form the official API in this case.

@@ -4,5 +4,17 @@ module Phlex::Rails::Helpers::OptionsForSelect
extend Phlex::Rails::HelperMacros

# [Rails Docs](https://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-options_for_select)
register_output_helper def options_for_select(...) = nil
def options_for_select(*args, **kwargs, &block)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should probably do this for options_from_collection_for_select too.

@joeldrapper joeldrapper added this to the 2.3 milestone May 8, 2025
Comment on lines +3 to +11
class Phlex::Rails::Never < BasicObject
def initialize(&block)
@block = block
end

def method_missing(method_name, *, **)
@block.call(method_name, *, **)
end
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is so creative!

Copy link
Collaborator Author

@joeldrapper joeldrapper May 8, 2025

Choose a reason for hiding this comment

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

You should see the PR I gave up on. It was popping things off the buffer. 🤣

The technique works but I thought it was too much to maintain.

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