0

I have model in my rails application by the name Request. Now I have integrated Ember inside a particular route in my application not the whole application, not sure if this is relevant information but giving it out anyway just in case. This is my ember routes:

VsRorDev.RequestsRoute = Ember.Route.extend(model: ->
  @get("store").findAll "request"
)

This is the template file(requests.hbs)

<h4>This is the index page of reqs</h4>
{{#each  model}}

<h4> {{id}} </h4>

{{/each}}

This is the ember model file

VsRorDev.Request = DS.Model.extend
    id: DS.attr('integer')
    service_id: DS.attr('integer')
    due_on: DS.attr('string')
    vendor_service_id: DS.attr('integer') 

This is the rails controller action in the Admin::EmberRequestsController

def index
    Rails.logger.info "********** INSIDE INDEX OF REQUEST*************"
    # @requests = determine_what_to_do
    @requests = Request.all
    render json: @requests
end

This is the serializer

class RequestSerializer < ActiveModel::Serializer
    attributes :id, :service_id, :due_on, :vendor_service_id, :workflow_step,:user_id,:created_at,:updated_at,:query,:admin_filter_payment_status_id,:admin_filter_status_id, :admin_filter_source_id, :admin_filter_priority_id,:admin_filter_due_by_id, :admin_filter_type_id, :admin_filter_lead_id, :admin_filter_payment_mode_id, :admin_filter_widget_id, :admin_filter_reminder_id, :agent_id, :deleted_at,:spam
end

The requests by ember are going to localhost:3000/requests while I want it to go to localhost:3000/admin/ember_requests. How do I do this?

4

1 回答 1

1

导轨部分

Rails 控制器可以通过适当的命名空间来更改,例如admin/ember。所以,你可以让你的 Rails 控制器像这样Admin::Ember::RequestsController

余烬部分

全局命名空间

您可以像这样配置应用程序适配器(store.js如果您使用的是ember-railsgem)

App.ApplicationAdapter = DS.ActiveModelAdapter.extend({ namespace: 'admin/ember' }); 现在,来自您的 ember 模型的所有请求都将发送给您一个 url/admin/ember/requests/admin/ember/posts.

特定型号

如果您只想向特定命名空间发出一个模型的请求,您可以像这样配置

App.RequestAdapter = DS.ActiveModelAdapter.extend({ namespace: 'admin/ember' });

请参阅emberjs 指南中的此自定义适配器部分

于 2014-05-25T04:57:13.537 回答