首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >是否可以在Radiant CMS中传递rails变量?

是否可以在Radiant CMS中传递rails变量?
EN

Stack Overflow用户
提问于 2011-03-07 06:35:16
回答 1查看 156关注 0票数 0

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

而且它似乎不允许任何rails助手生成form_for并实现身份验证令牌。

有人有幸在Radiant中安装了一个简单的form_for吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-03-07 08:45:52

在您的/your_extension.rb 中使用

代码语言:javascript
复制
def activate
  Page.send :include, YourCustomTags
end

your_custom_tags.rb

代码语言:javascript
复制
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

这将通过真实性。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5213954

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档