Sha256: ec6237e27e42d2d14a960f6bb59ddd1e4976ba36739d88ed6e8714d8fcabdfde
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
class RailsDetailMy::SectionsController < RailsDetailMy::BaseController def index @sort = Sort.find(params[:sort_id]) @sections = Section.find_all_by_sort_id(params[:sort_id]) end def new @section = Section.new @sort = Sort.find(params[:sort_id]) end def create @section = Section.new(params[:section]) @section.sort_id = params[:sort_id] @baike = Sort.find(params[:sort_id]) @baike.have_section = 1 @baike.save respond_to do |format| if @section.save format.html { redirect_to sort_sections_url(params[:sort_id]), :notice => '添加成功' } else format.html { render action: "new" } end end end def edit @section = Section.find(params[:id]) @sort = Sort.find @section.sort_id end def update @section = Section.find(params[:id]) @sort = Sort.find @section.sort_id respond_to do |format| if @section.update_attributes(params[:section]) format.html { redirect_to sort_sections_url(@sort), notice: "修改成功" } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @section.errors, status: :unprocessable_entity } end end end def destroy @section = Section.find(params[:id]) @sort = Sort.find @section.sort_id @section.destroy respond_to do |format| format.html { redirect_to sort_sections_url(@sort) } format.json { head :no_content } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_detail-0.0.1 | app/controllers/rails_detail_my/sections_controller.rb |