小编Chr*_*ley的帖子

在视图中显示Carrierwave文件名

我试图在Rails erb模板中显示Carrierwave附件的文件名.以下不起作用:

<%= @page.form.filename %>
Run Code Online (Sandbox Code Playgroud)

这似乎与文档一致.需要一些额外的步骤吗?

我的页面模型如下所示:

class Page < ActiveRecord::Base

  mount_uploader :form, FormUploader

end
Run Code Online (Sandbox Code Playgroud)

表单上传器如下所示:

class FormUploader < CarrierWave::Uploader::Base

  storage :file

  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end

  def extension_white_list
    %w(pdf)
  end

end
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails ruby-on-rails-3 carrierwave

50
推荐指数
6
解决办法
5万
查看次数

在Rails 4.2中使用redirect_to时,为什么有错误的参数错误?

在应用程序的Rails 4.1.1版本中,我在articles_controller中有以下创建方法:

def create
  @article = Article.new(article_params)
  authorize @article
  if @article.save
    flash[:notice] = "Successfully created article."
    redirect_to edit_article_path(@article)
  else
    render :new
  end
end
Run Code Online (Sandbox Code Playgroud)

但是,在更新到Rails 4.2后,尝试重定向时会出现以下错误:

wrong number of arguments (2 for 1)

为什么会出现此错误以及如何解决?

ruby-on-rails ruby-on-rails-4.2

15
推荐指数
1
解决办法
3080
查看次数

将phpBB BBCode帖子转换为Markdown

我有一个phpBB2论坛,帖子存储在BBCode中.论坛帖子在数据库中存储如下:

[quote:e5adceb8e8][quote:e5adceb8e8="Person 2"][quote:e5adceb8e8="Person 3"]Nested quote[/quote:e5adceb8e8]Another nested quote[/quote:e5adceb8e8]Some text[/quote:e5adceb8e8]

[b:e5adceb8e8]Some bold text[/b:e5adceb8e8]
[i:e5adceb8e8]italic text[/i:e5adceb8e8]
[u:e5adceb8e8]underlined text[/u:e5adceb8e8]

[code:1:e5adceb8e8]print &#40;&quot;hello world!&quot;&#41;;[/code:1:e5adceb8e8]

[img:e5adceb8e8]http://www.google.co.nz/intl/en_com/images/logo_plain.png[/img:e5adceb8e8]

[url]http://google.com[/url]

[url=http://google.com]Google[/url]

[color=darkred:e5adceb8e8]
Coloured text[/color:e5adceb8e8]

[size=18:e5adceb8e8]
Big text[/size:e5adceb8e8]

[list:e5adceb8e8]
List Item 1
List Item 2
[/list:u:e5adceb8e8]

[list:e5adceb8e8]
[*:e5adceb8e8]List Item 1
[*:e5adceb8e8]List Item 2
[/list:u:e5adceb8e8]

[list=1:e5adceb8e8]
[*:e5adceb8e8]List Item 1
[*:e5adceb8e8]List Item 2
[/list:o:e5adceb8e8]

[list=a:e5adceb8e8]
[*:e5adceb8e8]List Item 1
[*:e5adceb8e8]List Item 2
[/list:o:e5adceb8e8]
Run Code Online (Sandbox Code Playgroud)

我正在使用任何可以帮助我将此语法转换为Markdown的工具.理想情况下我只想要转换的[b],[i],[quote],[url],[code],和[list]标签.最好将[img]标记转换为Markdown中的链接,以避免页面调整大小问题.任何纯粹的表示元素(如[color][size]标签)都将转换为纯文本.

markdown phpbb bbcode

12
推荐指数
1
解决办法
2083
查看次数

如何在Ruby中限制Markdown语法?

我希望使用诸如MarakuKramdown之类的Ruby库在Rails CMS评论系统中实现Markdown .我需要限制用户可以提交的Markdown功能.在此系统中,不允许用户插入图像,html或执行任何繁重的编辑,但强调和超链接是可以的.

基本上,我希望创建类似于这个Textile过滤器的东西,但是对于Markdown语法.

ruby markdown ruby-on-rails

8
推荐指数
1
解决办法
1024
查看次数

使用acts-as-taggable-on更改默认分隔符

act-as-taggable-on gem中的默认分隔符是逗号.我想在整个Rails 3应用程序中将其更改为空格.例如,tag_list应该像这样分配:

object.tag_list = "tagone tagtwo tagthree"
Run Code Online (Sandbox Code Playgroud)

而不是像这样:

object.tag_list = "tagone, tagtwo, tagthree"
Run Code Online (Sandbox Code Playgroud)

更改分隔符的最佳方法是什么?

ruby-on-rails acts-as-taggable-on

5
推荐指数
1
解决办法
1192
查看次数