# POST /bumons
def create
@bumon = Bumon.new(params[:bumon])
bumonsyozoku = Bumonsyozoku.new
respond_to do |format|
if @bumon.save
bumonsyozoku.bumon_id = @bumon.id
bumonsyozoku.syozokbumon_id = @bumon.id
bumonsyozoku.syozokulevel = 0
bumonsyozoku.save
flag = params[:bumonsyozoku]["syozokubumon_id"]
if flag !=nil && flag !=""
parent_bumon = Bumonsyozoku.find(:all, :conditions => "bumon_id = #{flag}")
parent_bumon.each{|x| y=Bumonsyozoku.new ; y.bumon_id = @bumon.id; y.syozokulevel = x.syozokulevel + 1;y.syozokbumon_id=x.syozokbumon_id; y.save}
end
flash[:notice] = 'Bumon was successfully created.'
format.ext_json { render :json => @bumon.to_ext_json(:success => true) }
else
format.ext_json { render :json => @bumon.to_ext_json(:success => false) }
end
end
end
1 回答

吃鸡游戏
TA贡献1601条经验 获得超7个赞
rsepc 的话
describe 'bumons测试' do
before do
post :bumons,{ #你的测试数据}
end
it '逻辑测试' do
#你的逻辑
end
it '返回数据测试' do
#你期待的返回数据
end
end
- 1 回答
- 0 关注
- 7 浏览
添加回答
举报
0/150
提交
取消