Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails rails单选按钮自动提交_Ruby On Rails_Ruby_Ajax_Jquery_Ruby On Rails 3.2 - Fatal编程技术网

Ruby on rails rails单选按钮自动提交

Ruby on rails rails单选按钮自动提交,ruby-on-rails,ruby,ajax,jquery,ruby-on-rails-3.2,Ruby On Rails,Ruby,Ajax,Jquery,Ruby On Rails 3.2,我希望能够将图像对象的:albumcover设置为TRUE或FALSE。我如何使用ajax实现这一点,以便在选中单选按钮时提交? 非常感谢 查看 <% @images.each do |image| %> ... <%= label(:albumcover, 'Set as Album Cover ', :style => "float: left;") %> <%= radio_button_tag(:albumcover, "cover", fal

我希望能够将图像对象的
:albumcover
设置为TRUE或FALSE。我如何使用ajax实现这一点,以便在选中单选按钮时提交? 非常感谢

查看

<% @images.each do |image| %>
...
  <%= label(:albumcover, 'Set as Album Cover ', :style => "float: left;") %>
  <%= radio_button_tag(:albumcover, "cover", false, :id => :albumcover_tag) %>
...
<% end %>
尝试使用Ajax

$(function(){
$('#albumcover_tag').bind('click', function(){
    $.ajax({
        url: "<%= update_form_admin_album_images_path %>",
        data: $('#albumcover_tag').val(),
    }).success(function(){
        alert("success");
    });
});
});
$(function(){
$('#albumcover_tag').bind('click', function(){
    $.ajax({
        url: "<%= update_form_admin_album_images_path %>",
        data: $('#albumcover_tag').val(),
    }).success(function(){
        alert("success");
    });
});
});
create_table "images", :force => true do |t|
    t.string   "title"
    t.string   "description"
    t.datetime "date"
    t.integer  "album_id"
    t.integer  "image_id"
    t.binary   "picture"
    t.boolean  "albumcover"
  end