Skip to content

Instantly share code, notes, and snippets.

@sinsoku
Last active June 11, 2019 11:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sinsoku/f18ab57d04b8bacc31265d57050979d6 to your computer and use it in GitHub Desktop.
Save sinsoku/f18ab57d04b8bacc31265d57050979d6 to your computer and use it in GitHub Desktop.
<% A.foo(@user) do |f| %>
<%= f.label :name %>
<%= f.text_field :name %>
<% end %>
module A
def self.foo(obj, options = {}, &block)
# もっと簡単な方法は無いものか...
options[:url] ||= Rails.application.routes.url_helpers.polymorphic_path(obj, format: :json)
options[:builder] ||= CustomBuilder
# これも良いのか微妙
ApplicationController.helpers.form_for(obj, options, &block)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment