任何使用ember数据推荐的示例应用程序?理想情况下使用Rails后端和模型关联.
我有一个包含图像的Rails3邮件程序布局.
这些使用如下:
image_tag("emails/top.gif", :width => "700", :height => "10", :alt => "")
Run Code Online (Sandbox Code Playgroud)
从Rails 2开始,这些图像包括主机并产生了预期的结果.但是,由于Rails3 config.action_mailer.default_url_options
似乎被忽略了.
有什么我想念的吗?
更新
我的config/environment/development.rb包括:
config.action_mailer.default_url_options = { :host => 'mydomain.tld' }
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用FontAwesome制作带有无线电收集的星级评级表,为此我实际上需要更改simple_form生成的collection_radio_button输入的标签类,但找不到任何明显的解决方案.
到目前为止我使用:
form_for @user do |f|
f.collection_radio_buttons :rating, [[1, 'Bad'] ,[2, 'Ok'], [3, 'Great']],
:first, :last, { item_wrapper_tag: false }
end
Run Code Online (Sandbox Code Playgroud)
哪个产生:
<input id="review_rating_1" name="review[rating]" type="radio" value="1" />
<label class="collection_radio_buttons" for="review_rating_1">Bad</label>
<input id="review_rating_2" name="review[rating]" type="radio" value="2" />
<label class="collection_radio_buttons" for="review_rating_2">Ok</label>
<input id="review_rating_3" name="user[options]" type="radio" value="3" />
<label class="collection_radio_buttons" for="review_rating_3">Great</label>
Run Code Online (Sandbox Code Playgroud)
但我希望标签有一个额外的类,如:
<input id="review_rating_3" name="user[options]" type="radio" value="3" />
<label class="collection_radio_buttons icon-star" for="review_rating_3">Great</label>
Run Code Online (Sandbox Code Playgroud)
更新:此类在静态定义:https://github.com/plataformatec/simple_form/blob/master/lib/simple_form/tags.rb#L43
我正在尝试观察路线更改,以便在渲染后应用一些常见操作.我们的想法是拥有onload
与之类似的功能,但是当我们使用单页应用时,需要在每次路由更改时触发.(可以限定为新视图)
我找到了如何观察currentPath的变化:
App.ApplicationController = Ember.Controller.extend({
currentPathDidChange: function() {
prettyPrint()
}.observes('currentPath');
});
Run Code Online (Sandbox Code Playgroud)
虽然这在某些情况下效果很好,但是当路由发生变化时会触发它,但仍然要提前应用内容更改,因为它似乎在内容呈现之前附加.
有关实现这一目标的最佳实践的任何想法?
在这种情况下,我觉得代码说的不仅仅是单词,所以放在代码中:
配置/ routes.rb中
namespace :embed do
namespace :v1 do
resources :articles
end
end
Run Code Online (Sandbox Code Playgroud)
应用程序/控制器/嵌入/ V1/articles_controller.rb
class Embed::V1::ArticlesController < ApplicationController
def index
render :text => 'ok'
end
end
Run Code Online (Sandbox Code Playgroud)
规格/控制器/嵌入/ V1/articles_controller_spec.rb
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Embed::V1::ArticlesController do
it "should do something" do
get :new
end
end
Run Code Online (Sandbox Code Playgroud)
运行 rspec spec
$ rspec spec
F
Failures:
1) Embed::V1::ArticlesController should do something
Failure/Error: get :new
AbstractController::ActionNotFound:
The action 'new' could not be found for Embed::V1::ArticlesController
# ./spec/controllers/embed/v1/articles_controller_spec.rb:5
Finished in 0.01665 seconds
1 example, 1 …
Run Code Online (Sandbox Code Playgroud) 使用Rails的2.3.11,我创建管理平台是一个插件添加方法来ApplicationController
.
我在插件中创建了以下模块:
module ApplicationControllerPatch
def self.included(base) # :nodoc:
base.class_eval do
rescue_from AnException, :with => :rescue_method
def rescue_method(exception)
...
end
end
end
end
Run Code Online (Sandbox Code Playgroud)
现在,如果我将此模块直接包含在application_controller.rb
文件中,如下所示:
class ApplicationController < ActionController::Base
include ApplicationControllerPatch
...
end
Run Code Online (Sandbox Code Playgroud)
一切正常,但是我想通过从插件本身包含这个模块来避免编辑核心源代码.到目前为止,如果我这样做:
ApplicationController.send(:include, ApplicationControllerPatch)
Run Code Online (Sandbox Code Playgroud)
直接来自这个模块文件(位于插件文件夹中).这将为请求正确加载,然后由控制器覆盖(我猜).
完成此任务的方法是什么?
ember.js ×2
ruby ×2
controller ×1
ember-data ×1
image ×1
layout ×1
mailer ×1
observers ×1
path ×1
plugins ×1
redmine ×1
routes ×1
routing ×1
rspec ×1
simple-form ×1