新建及编辑改进

This commit is contained in:
huang 2017-03-22 15:48:06 +08:00
parent ac0f3f7358
commit 5a8f4be6e5
4 changed files with 12 additions and 9 deletions

View File

@ -42,13 +42,13 @@ class ChallengesController < ApplicationController
end
end
end
if params[:knowledge][:input].length > 0
unless params[:knowledge].blank?
params[:knowledge][:input].each do |input|
ChallengeTag.create(:name => input, :challenge_id => @challenge.id)
end
end
respond_to do |format|
format.html {redirect_to shixun_challenge_path(@challenge, :shixun_id => @shixun)}
format.html {redirect_to shixun_challenge_path(@challenge, :shixun_id => @shixun), notice: '创建成功!'}
end
else
respond_to do |format|
@ -80,7 +80,10 @@ class ChallengesController < ApplicationController
end
def destroy
@challenge.destroy
respond_to do |format|
format.html{redirect_to shixun_challenges_path(@shixun)}
end
end
def update
@ -104,13 +107,13 @@ class ChallengesController < ApplicationController
end
end
end
if params[:knowledge][:input].length > 0
unless params[:knowledge].blank?
params[:knowledge][:input].each do |input|
ChallengeTag.create(:name => input, :challenge_id => @challenge.id)
end
end
end
format.html {redirect_to shixun_challenge_path(@challenge, :shixun_id => @shixun), notice: 'Shixun was successfully created.'}
format.html {redirect_to shixun_challenge_path(@challenge, :shixun_id => @shixun), notice: '更新成功!'}
format.json { head :no_content }
else
format.html { render action: "edit" }

View File

@ -267,7 +267,7 @@
}else if($("#challenge_score").val().trim()==""){
$("#new_shixun_score").show();
}else{
$('#new_challenge').submit();
$('#challenge_shixun_create').submit();
}
}
@ -279,7 +279,7 @@
}else if($("#challenge_score").val().trim()==""){
$("#new_shixun_score").show();
}else{
$('#edit_challenge_48').submit();
$('#edit_challenge_<%= @challenge.id %>').submit();
}
}
</script>

View File

@ -11,7 +11,7 @@
</div>
<div class=" panel-form ">
<ul>
<%= labelled_form_for @challenge, :url => shixun_challenges_path(@shixun) do |f| %>
<%= labelled_form_for @challenge, :url => shixun_challenges_path(@shixun), :html => {:id => "challenge_shixun_create"} do |f| %>
<%= render :partial => "form", :locals => {:f => f} %>
<% end %>
</ul>

View File

@ -9,7 +9,7 @@
<h3 class="fl panel-inner-title"><span class="color-red mr10">第<%= @challenge.position %>关</span><%= @challenge.subject %></h3>
<p class="fr">
<a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun) %>" title="编辑"><i class="fa fa-pencil-square-o color-grey font-16 mr5"></i></a>
<a href="#" title="删除"><i class="fa fa-trash-o color-grey font-16 mr5"></i></a>
<a href="<%= shixun_challenge_path(@challenge, :shixun_id => @shixun) %>" title="删除" methods="delete"><i class="fa fa-trash-o color-grey font-16 mr5"></i></a>
<!--<a href="#" title="复制"><i class="fa fa-files-o color-grey font-16 mr5"></i></a>-->
</p>
</div>