0
我有一个角度的应用程序在轨道上运行,并试图从我的轨道后端与参数获取数据,它总是只返回所有投票。我认为我的问题在我的后端。Rails没有使用我的参数发送数据
它总是调用索引行动,但它不使用的参数,有人请帮助我得到这个工作
这里是服务器输出
Started GET "/api/v1/votes.json?votable_id=129&votable_type=Post" for 127.0.0.1 at 2014-08-28 13:16:51 -0700
Processing by Api::V1::VotesController#index as JSON
Parameters: {"votable_id"=>"129", "votable_type"=>"Post"}
Vote Load (0.3ms) SELECT "votes".* FROM "votes" ORDER BY id DESC
Completed 200 OK in 8ms (Views: 5.2ms | ActiveRecord: 0.3ms)
这里是我的控制器
module Api
module V1
class VotesController < ApplicationController
respond_to :json
def index
respond_with(Vote.all.order("id DESC"))
end
def show
respond_with(Vote.find(params[:id]))
end
def create
@vote = Vote.new(vote_params)
@vote.save
respond_with @vote, location: ""
end
def update
@vote = Vote.find(params[:id])
@vote.update(vote_params)
respond_with @vote, location: ""
end
def destroy
respond_with Vote.destroy(params[:id])
end
private
def vote_params
params.require(:vote).permit(:vote, :votable_id, : votable_type, :user_id)
end
end
end
end