Use client vidatation for topic/comments

This commit is contained in:
Rei
2014-02-16 21:15:26 +08:00
parent 513969c7c0
commit b0bacede5e
4 changed files with 32 additions and 2 deletions

View File

@@ -10,3 +10,12 @@
= f.submit 'Save changes', class: 'btn btn-success'
'
a.btn.btn-default href=cancel_comment_path(comment) data-remote="true" Cancel
javascript:
$('#edit_comment_#{comment.id}').validate({
rules: {
'comment[body]': {
required: true
}
}
});

View File

@@ -1,4 +1,4 @@
= form_for @topic, remote: true, html: { class: 'form-topic' } do |f|
= form_for @topic, remote: true, html: { class: 'topic-form' } do |f|
.row
.col-md-9
.form-group
@@ -14,3 +14,17 @@
= f.submit 'Save changes', class: 'btn btn-success', tabIndex: 4
'
a.btn.btn-default href=topic_path(@topic) tabIndex="5" Cancel
- form_id = @topic.new_record? ? 'new_topic' : "edit_topic_#{@topic.id}"
javascript:
$('##{form_id}').validate({
rules: {
'topic[title]': {
required: true
},
'topic[body]': {
required: true
}
}
});

View File

@@ -88,3 +88,11 @@
javascript:
campo.Likes.updateLikes('comment', #{current_user.likes.where(likeable_type: 'Comment', likeable_id: @comments.pluck(:id)).pluck(:likeable_id)});
$('#new_comment').validate({
rules: {
'comment[body]': {
required: true
}
}
});

View File

@@ -27,7 +27,6 @@ class Admin::UsersControllerTest < ActionController::TestCase
assert_difference "User.count", -1 do
delete :destroy, id: user
end
assert_redirected_to admin_users_path
end
test "should lock user" do