views:

34

answers:

1

HAML:

= link_to 'redeem', redeem_admin_organization_path(organization), :class => 'button_short live redeem'

Controller:

def redeem
  @organization = Organization.find(params[:id])
  @organization.update_attribute('accumulated_credits', '0')
end

redeem.js.haml:

== $("#organization_#{@organization.id} .redeem").html("#{escape_javascript(link_to('redeem', redeem_admin_organization_path(@organization), :class => 'button_short live redeem'))}");

This is returning the error:

NoMethodError (undefined method `accumulated_credits=' for #<Organization:0x2f3242c>):
A: 

Doesn't look like the error is haml or json related -- I think it's in the @organization.accumulated_credits assignment; looks like it doesn't exist

Can you confirm that exists (either through schema.rb or using the console?)

@organization.update_attribute('accumulated_credits', '0')
...
NoMethodError (undefined method `accumulated_credits=' for #<Organization:0x2f3242c>):
Jesse Wolgamott
Aha! I can only retrieve this data in IRB such as Organization.first.accumulated_credits (returns 0). But if I do Organization.first.update_attribute('accumulated_credit', '0'), it gives me the same error as above. What does that mean?
Trip
I got it. It was because this attribute was not attached to this model. Thus the problem :D But your pointer made me figure that out. Thanks
Trip