0

我正在尝试为邮件列表设置一个简单的表单。

而且它似乎不允许任何 Rails 助手制作 form_for 并完成真实性令牌。

任何人都可以在 Radiant 中安装一个简单的 form_for 吗?

4

1 回答 1

1

在你的/your_extension.rb

def activate
  Page.send :include, YourCustomTags
end

your_custom_tags.rb

module YourCustomTags
  include Radiant::Taggable

  tag 'custom' do |tag|
    tag.expand
  end

  tag "custom:form" do |tag|
    tag.attr['id'] ||= 'newsletter'
    results = []
    action = "/newsletters/"
    results << %(<form action="#{action}" method="post" #{newsletter_attrs(tag)}>)
    results << %(<input name="authenticity_token" type="hidden" value="#{response.instance_variable_get(:@session)[:_csrf_token]}" />)
    results <<   tag.expand
    results << %(</form>)
  end

这将通过真实性。

于 2011-03-07T00:45:52.347 回答