我安装插件open_id_authentication并出现此错误:
/usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:167:in `require': no such file to load -- rack/openid (LoadError)
Run Code Online (Sandbox Code Playgroud)
当我尝试启动时rails server
,在我的系统中安装了rack-openid,我可以从irb加载它:
irb(main):001:0> require 'rack/openid'
=> true
Run Code Online (Sandbox Code Playgroud)
我尝试像使用ruby-openid一样添加hack到Gemfile,但它没有帮助:
gem "ruby-openid", :require => "openid"
gem "rack-openid", :require => "rack/openid"
Run Code Online (Sandbox Code Playgroud)
我也试过了
gem "ruby-openid", :require => "rack/openid"
Run Code Online (Sandbox Code Playgroud)
但:
/usr/lib/ruby/gems/1.9.1/gems/bundler-0.9.7/lib/bundler/runtime.rb:38:in `require': no such file to load -- rack/openid (LoadError)
Run Code Online (Sandbox Code Playgroud)
在rails 2.3.5 app中没有这个问题,我无法理解为什么它会在Rails 3中发生.
我是rails的新手,最近我发现了rails_admin.
我使用rails_admin文档中的命令添加了CKEditor,但我不知道如何在字段上启用它.
我正在开发一个Rails插件,其中包含一种修改has_many中关联记录顺序的方法:通过关联.假设我们有以下型号:
class Playlist < ActiveRecord::Base
has_many :playlists_songs, :dependent => :destroy
has_many :songs, :through => :playlists_songs
end
class Song < ActiveRecord::Base
has_many :playlists_songs, :dependent => :destroy
has_many :playlists, :through => :playlists_songs
end
class PlaylistsSong < ActiveRecord::Base
belongs_to :playlist
belongs_to :song
end
Run Code Online (Sandbox Code Playgroud)
如果我们改变播放列表歌曲的顺序(例如@playlist.songs.rotate!),Rails不会触及playlists_songs表中的记录(我正在使用Rails 3.1),这是有道理的.我想调用播放列表的歌曲=方法保存歌曲的顺序,但是,可以通过删除播放列表中的相关现有行并以正确的顺序创建新的行(这样:order => "id"可以在检索它们时使用)或者通过向playlists_songs添加sort:integer列并相应地更新这些值.
我没有看到任何允许这样做的回调(例如before_add).在ActiveRecord :: Associations :: CollectionAssociation中,相关的方法似乎是writer,replace和replace_records,但我对最好的下一步将会失败.有没有办法扩展或安全地覆盖这些方法之一,以允许我正在寻找的功能(最好只针对特定的关联),或者是否有一个不同的,更好的方法呢?
activerecord ruby-on-rails associations has-many-through ruby-on-rails-plugins
我必须将类似Wufoo的WYSIWYG表单构建器功能添加到Rails webapp.
有谁知道有用的好资源(宝石/引擎/插件/示例代码)?
根据http://edgeapi.rubyonrails.org/classes/Rails/Railtie.html,如果我写一个Rails 3插件并且我想挂钩初始化过程,我写
class MyRailtie < Rails::Railtie
initializer "my_railtie.configure_rails_initialization" do
# some initialization behavior
end
end
Run Code Online (Sandbox Code Playgroud)
但是,这个初始化程序似乎在您运行Rails rake任务时执行,而不仅仅是在您运行rails s或类似时执行.我的问题是,如何防止在Rails任务期间运行此块中的代码,而不是完整的Rails服务器启动?这似乎是Rails 3插件的常见问题.
我在这里开发一个简单的插件,而且这个目的正在发挥作用.除了我的助手.它是一个非常简单的帮助器,它只需要回显一个<span></span>以后的javascript解析.
问题是,它没有使html正确,它用html等效代码替换特殊字符.
我的插件初始化程序:
ActionView::Helpers.send :include, Test
Run Code Online (Sandbox Code Playgroud)
我的插件助手:
module Test
def only_for_testing
render(:text => "<span></span>")
end
end
Run Code Online (Sandbox Code Playgroud)
当我在视图中调用only_for_testing帮助器时,而不是渲染"<span></span>"它呈现" <span></span>"
我尝试删除渲染,只返回字符串,效果相同.我真的不想为此创建一个部分,因为它是一个非常非常简单的html,它不是用于布局,它只是用于解析.
知道我在这里做错了什么吗?
我想在Rails中使用插件系统创建一个应用程序.潜在用户应该能够上传(或更好地从存储库安装)一个插件并安装它,使我的应用程序能够做更多的事情.这应该在没有FTP/SSH /任何低级访问服务器的情况下完成.
那么有没有关于如何在Rails 3中完成它的好的宝石或教程?
Facebook刚刚重新启动了评论,具有自动语法修复功能.
语法过滤器有什么作用?
- 添加标点符号(例如句子末尾的句点)
- 修剪额外的空白自动案例单词(例如,将句子的第一个单词大写)
- 扩大俚语(例如,PLZ变为请)
- 在标点符号后添加空格(例如Hi,Cat会变成Hi,Cat)
- 修复常见的语法错误(例如将'不要'转换为'不要')
什么是等效的插件或宝石?
我用过这些设置
WickedPdf::config = {
:layout => 'application.pdf.html', # use 'pdf.html' for a pfd.html.erb file
:wkhtmltopdf => '/bin/wkhtmltopdf', # path to binary
:orientation => 'Portrait', # default , Landscape
:page_size => 'A4',
:dpi => '300',
:print_media_type => true,
:no_background => true,
:margin => {:top => 0, # default 10 (mm)
:bottom => 0,
:left => 0,
:right => 0},
}
Run Code Online (Sandbox Code Playgroud)
并将体型设置为
body {
margin: 0;
padding: 0;
background-color: #FFF;
width: 210mm;
height: 297mm;
}
Run Code Online (Sandbox Code Playgroud)
和一个班级.page
.page {
display: inline-block;
clear: both; …Run Code Online (Sandbox Code Playgroud) 我在我的Rails应用程序中使用CanCan获取权限,我在其中为一些通用表单功能构建了自己的引擎.我想锁定系统中的权限,以便用户无法自由访问我的引擎控制器的操作.这些控制器大多只使用7个REST动作,所以我想load_and_authorize_resource在每个控制器的顶部使用CanCan .
但是,当我像这样编写代码时:
module MyEngine
class FormController < ApplicationController
load_and_authorize_resource
...
end
end
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
uninitialized constant Form
Run Code Online (Sandbox Code Playgroud)
我的猜测是,自动装弹机中load_and_authorize_resource被绑定到我的MainApp命名空间,并且不承认,我在不同的命名空间调用它,所以确实喜欢打电话Form.find(params[:id]),而不是MyEngine::Form.find(params[:id]).
如果是这种情况,我该如何解决这个问题?这不是一个大问题,因为authorize!仍然可以正常工作,所以我可以单独定义每个动作中的授权,但如果我能够使用该load_and_authorize_resource方法,它会感觉更清洁.
ruby ×2
activerecord ×1
associations ×1
cancan ×1
gem ×1
helpers ×1
plugins ×1
rack ×1
regex ×1
rubygems ×1
webforms ×1
wkhtmltopdf ×1
wysiwyg ×1