您认为在Rails应用程序中实现了哪些行为可以很好地作为插件存在?
您在过去搜索过哪些插件功能但找不到?
什么现有的Rails插件可以改进或扩展,以及如何?
你知道jrails的另一种选择吗?
它或多或少过时(使用jQuery 1.5 - 现在1.7是当前版本).
有人知道另一种选择吗?
谢谢
编辑:
我知道如何用jquery allone构建rails助手 - 但我喜欢rails助手,所以我不想使用jquery allone(没有jrails)
delayed_job处理完任务后,我需要更新模型,例如:
foo.delay.something
完成后something,我需要更新foo对象,实现此目的的最佳方法是什么?我当时在想在Delayed::Backend::ActiveRecord::Job类上编写回调,但是应该做得更好一些。
我找到了一种方法来自定义设备使用用户名登录而不是电子邮件地址.
但实际上我想使用组合: -
Enter username or Email: <text-box>
Enter your password : <text-box>
Run Code Online (Sandbox Code Playgroud)
那么如何实现呢?
实际上我们需要修改devise gem的配置来支持它.
现在我知道修改"/config/initializers/devise.rb"文件为
config.authentication_keys = [ :username ] (edited from email to username.)
Run Code Online (Sandbox Code Playgroud)
实际上会使用username而不是emailid启用登录.
但我可以做一些事情: -
config.authentication_keys = [ :username | :email] in the "config/initializers/devise.rb" file.
Run Code Online (Sandbox Code Playgroud)
因此,我们设计可以在运行时将用户名或电子邮件作为身份验证密钥,具体取决于用户提供的输入.
提前致谢 .
authentication ruby-on-rails ruby-on-rails-plugins devise ruby-on-rails-3
我有一段时间在工作中获得可行的标记.我是Ruby/RoR的新手,我觉得有时候这些插件(虽然很棒)缺乏对不习惯在Rails中工作的人的基本实现指令.
我有一个简单的内容模型,我希望能够添加标签.当我保存表单时,没有任何反应.我尝试输出标签,没有任何显示(我已经进入rails控制台,没有).我的内容模型(表格)上是否需要其他属性(列)?我有一种感觉,我错过了一些非常基本的东西.
内容模型:
class Content < ActiveRecord::Base
acts_as_taggable
# I've also tried acts_as_taggable :tags
end
Run Code Online (Sandbox Code Playgroud)
在我的形式部分:
<p>
<%= f.label 'Tags' %><br />
<%= f.text_field :tag_list %>
</p>
Run Code Online (Sandbox Code Playgroud)
在我的show.html.erb中:
<p>
<strong>Tags</strong>:
<% for tag in @content.tags %>
<%= link_to tag.name, contents_path(:view =>'tag', :tag => tag.name) %>
<% end %>
</p>
Run Code Online (Sandbox Code Playgroud)
我希望有人能让我指出正确的方向.谢谢!
编辑
这是日志的链接,你可以看到它保存了tag_list.
我在Rails 3上运行了ambethia的reCAPTCHA插件.有谁知道如何覆盖它的flash消息标记?我想重用我自己的flash_errordiv id而不是使用插件的flash_recaptcha_errordiv id:
<div id="flash_recaptcha_error">incorrect-captcha-sol</div>
Run Code Online (Sandbox Code Playgroud)
另外,你如何清理这个控制器#create?
def create
@post = Post.new(params[:post])
respond_to do |format|
if verify_recaptcha(:model => @post, :error => "reCAPTCHA incorrect. Try again.") && @post.save
flash.now[:notice] = "Created \"#{@post.title}\""
format.html { redirect_to(@post, :notice => 'Post was successfully created.') }
else
flash.now[:error] = "Incorrect word verification. Are you sure you\'re human?"
format.html { redirect_to(:back, :error => 'reCAPTCHA incorrect. Try again.') }
end
end
end
Run Code Online (Sandbox Code Playgroud)
感谢您阅读我的问题.
controller ruby-on-rails recaptcha ruby-on-rails-plugins ruby-on-rails-3
我有一个Rails应用程序,我正在尝试将Rails引擎集成到.
主机应用程序有一些捕获所有路线:
# magic urls
match '/' => 'admin/rendering#show'
match '*path/edit' => 'admin/rendering#show', :defaults => { :editing => true }
match '*path' => 'admin/rendering#show'
Run Code Online (Sandbox Code Playgroud)
看起来应用程序捕获所有路由后加载引擎路由.
/sitemap.xml(.:format) {:format=>"xml", :controller=>"admin/sitemaps", :action=>"show"}
/(.:format) {:controller=>"admin/rendering", :action=>"show"}
/*path/edit(.:format) {:controller=>"admin/rendering", :action=>"show"}
/*path {:controller=>"admin/rendering", :action=>"show"}
engine_envs GET /engine/envs/:id(.:format) {:controller=>"engine/envs", :action=>"show"}
PUT /engine/envs/:id(.:format) {:controller=>"engine/envs", :action=>"update"}
jammit /assets/:package.:extension(.:format) {:extension=>/.+/, :controller=>"jammit", :action=>"package"}
Run Code Online (Sandbox Code Playgroud)
到目前为止,一切都在击中/engine/envs路线被应用程序捕获所有路线.但是我发现堵塞路线是在发动机后加载的,我不相信那些被抓住了.有没有办法覆盖应用程序路线?
routes ruby-on-rails ruby-on-rails-plugins rails-engines ruby-on-rails-3
对于我的Rails项目,我正在寻找一个可以转换质量,体积和其他单位的库.
我需要将kilogramms转换为gramms,升转换成汤匙等.
我想,它应该是这样的:
class Product < ActiveRecord:Base
acts_as_physical_unit, :volume, :mass, :count
end
class Ingredient < ActiveRecord:Base
acts_as_physical_unit, :volume, :mass, :count
end
olive_oil = Product.new(:name => "Olive Oil", :volume => "1000 ml")
caesar_salad = Recipe.new(:name => "Caesar salad",
:ingredients => [
Ingredient.new(:product => [olive_oil], :volume => "5 tablespoons")
]
# In ingredients of "Caesar Salad" are 5 tablespoons of "Olive Oil" specified.
# We should create "Caesar Salad" for 50 persons.
# How mutch bottles of "Olive Oil" should be ordered …Run Code Online (Sandbox Code Playgroud) gem units-of-measurement ruby-on-rails-plugins ruby-on-rails-3
假设我创建了一个名为"Soho"的可安装引擎,该引擎具有"用户"控制器.我可以转到/ users/1查看ID为1的用户.
在'Soho'里面,我有一个application.html.erb用于布局.
现在让我们假设我想在一个名为'Soho_test'的应用程序中"混合"我的引擎'Soho',然后将我的引擎挂载到"/".因此,在我的主机应用程序'Soho_test'中,我也可以在/ users/1中查看ID为1的用户.这是有效的.
我的问题是:如何在我的主机应用程序'Soho_test'中将'Soho_test'application.html.erb应用于/ users/1(用户配置文件页面)而不是'Soho'可安装引擎中的那个?
谢谢!
非常奇怪的问题:我有一个2部分的下拉列表,选择一个州将添加第二个下拉列表,为您提供该州的MSA区域列表.
这是通过对控制器的JQuery Get请求来完成的,该控制器返回Select下拉列表中的区域列表,例如
jQuery(function($) {
// when the #area_state field changes
$("#area_state").change(
function() {
// make a call and replace the content
var state = $('select#area_state :selected').val();
if(state == "") state="0";
jQuery.get(
'/getmsas/' + state,
function(data){ $("#msas").html(data); }
)
return false;
}
);
})
Run Code Online (Sandbox Code Playgroud)
注 - 此代码改编自此处的教程:http://www.petermac.com/rails-3-jquery-and-multi-select-dependencies/
这在Chrome和IE中运行良好,但在Firefox(13.0.1)中它不起作用,产生两个错误:
Error: junk after document element
Source File: http://localhost:3000/getmsas/Connecticut
Line: 2, Column: 1
Source Code:
<select id="area_msa" name="area[msa]"><option value="">Select Area (Optional)</option>
Run Code Online (Sandbox Code Playgroud)
和
Error: uncaught exception: [Exception... "Node cannot be inserted …Run Code Online (Sandbox Code Playgroud)