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?

Aravind
  • 1,391
  • 1
  • 16
  • 41

1 Answers1

1

RAILS PART

The Rails controller can be changed with proper namespacing something like this admin/ember. So, you can have your Rails controller as something like this Admin::Ember::RequestsController

Ember Part

Global namespace

You could configure the application adapter something like this (in store.js if you are using ember-rails gem)

App.ApplicationAdapter = DS.ActiveModelAdapter.extend({ namespace: 'admin/ember' }); Now, all requests from your ember model will be made to you an url /admin/ember/requests or /admin/ember/posts.

Model specific

If you just want only one model's request to be made to a specific namespace, you could configure like this

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

Refer this customizing adapters part in emberjs guides

Vysakh Sreenivasan
  • 1,719
  • 1
  • 16
  • 27