0
我使用Rails 4.我试着给我button_to形成类:轨button_to类变化
<%= button_to "unsubscribe",
:form_class => 'unsubscribe',
:controller => :places,
:action => 'delid',
:plid => subscription.place.id,
:method => :post %>
但窗体类是“button_to”
控制器看起来是这样的:
def delid
@lolka = Subscription.where(user_id: current_user.id, place_id: params[:plid]).destroy_all
@subscribed = Place.find_by_id(params[:plid])
@subscribed.update_attributes(:subscribers_count => Subscription.where(place_id: params[:plid]).count)
@subscribed.update_attributes(:subscribers_male => Subscription.where(place_id: params[:plid], user_gender: 'male').count)
@subscribed.update_attributes(:subscribers_female => Subscription.where(place_id: params[:plid], user_gender: 'female').count)
@places = Place.all
redirect_to :back
end
也许我做错了什么?并且最好使用link_to?但是如何?提前致谢。
为我工作。谢谢。价值或其他html选项在第二? – AlexEfremo