ruby on rails - emberjs assertion failed error -
i trying insert data ember's view getting following error message:
uncaught error: assertion failed: server returned hash key refunds have no mapping and here coding can correct it.
my handlebar
<form> <th>{{view ember.textfield valuebinding="refund_amount" placeholder="enter refund amount"}}</th> <td><button type="submit" class="btn btn-success complete-btn" {{action saverefund}}>refund</button></td> </form> my js model
office.refund = ds.model.extend({ job_id: ds.attr('number'), customer_id: ds.attr('number'), amount: ds.attr('number') }); my js controller
saverefund: function() { var refund = office.refund.createrecord({ job_id: this.get('id'), customer_id: this.get('customer.id'), amount: this.get('refund_amount') }); this.get('store').commit(); refund.on('didcreate',function() { alert('created successfully'); }); } here refund_controller.rb
def index @refund = thunderbolt::refund.all respond_to |format| format.html # index.html.erb format.json { render json: @refund} end end def new @refund = refund.new respond_to |format| format.html # new.html.erb format.json { render json: @refund } end end def create refunds = params[:refund] @refund = refund.new(job_id: refunds[:job_id], customer_id: refunds[:customer_id], amount: refunds[:amount]) respond_to |format| if @refund.save format.html { redirect_to @refund, notice: 'refund successful.' } format.json { render json: @refund, status: :created, location: @refund } else format.html { render action: "new" } format.json { render json: @refund.errors, status: :unprocessable_entity } end end end here refund_serializer.rb
class refundserializer < activemodel::serializer attributes :id, :job_id, :customer_id, :amount, :created_at, :updated_at end here refund.rb model
class refund < activerecord::base attr_accessible :id, :amount, :customer_id, :job_id, :created_at, :updated_at end
solved error adding resources :refunds in routes.rb instead of
"refunds/index" "refunds/new" "refunds/edit" "refunds/show"
Comments
Post a Comment