Skip to content

Instantly share code, notes, and snippets.

@kmelkon
Last active December 21, 2015 17:09
Show Gist options
  • Save kmelkon/6338861 to your computer and use it in GitHub Desktop.
Save kmelkon/6338861 to your computer and use it in GitHub Desktop.
<address>
<%= deal.value %><br>
<%= deal.background %><br>
</address>
<div class="no-radio">
<div class="btn-group" data-toggle="buttons-radio">
<%= form_tag status_deal_path(deal), :remote => true, :class => "deals_status" do %>
<%= radio_button_tag :state, "won"+deal.id.to_s, deal.state == "won", :class => "toggle-btn-left toggle-btn" %>
<%= label_tag 'state_won'+deal.id.to_s, "won", :class=>"btn" %>
<%= radio_button_tag :state, "lost"+deal.id.to_s, deal.state == 'lost', :class => "toggle-btn-center toggle-btn" %>
<%= label_tag 'state_lost'+deal.id.to_s, "lost",:class=>"btn" %>
<%= radio_button_tag :state, "pending"+deal.id.to_s, deal.state == 'pending',:class => "toggle-btn-right toggle-btn" %>
<%= label_tag 'state_pending'+deal.id.to_s, "pending", :class=>"btn" %>
<% end %>
</div>
</div>
$("body").on("change", "form :radio", function(){
$(this).closest("form").submit();
});
$('.deals-wrapper').append('<%= escape_javascript(render :partial => "deals/deal", :locals => {:deal => @deal}) %>');
def status
@deal = Deal.find_by_id(params[:id])
@deal.update_attribute(:state, params[:state])
respond_to do |format|
format.js
end
end
Started POST "/__better_errors/70101218397900/variables" for 127.0.0.1 at 2013-08-26 10:29:39 +0300
Task Load (0.2ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."company_id" = 31
NoMethodError at /companies/31
undefined method `value' for nil:NilClass
local_assigns
{:locals=>{:deal=>#<Deal id: 24, company_id: 31, name: "deal", background: "deak", currency: "", value: 22.0, offer: nil, deal_category_id: nil, deal_status_id: nil, user_id: nil, created_at: "2013-08-25 06:34:17", updated_at: "2013-08-26 07:12:04", status: nil, state: "won">}, :deal=>nil}
Request parameters
{"action"=>"show", "controller"=>"companies", "id"=>"31"}
<div class="deals-wrapper">
<% @deals.each do |deal| %>
<%= render 'deals/deal', :locals => {:deal => deal} %>} %>
<% end %>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment