问题描述:

I´m using a form like this:

<%= form_for student.account, remote: true do |f| %>

<% student.account.attributes.each do |key, value| %>

<span class="btn btn-danger student-payment" id="account-<%= key %>" name="account[<%= key %>]" checked="true"><%= key %></span>

<% end %>

<% end %>

This gives me a certain amount of buttons. In the model, for each key the value is false per default and by pressing the button the value should change to true (and back).

Coffee-script for the button:

$('.student-payment').click ->

btn = $(this)

btn.parent('form').submit()

The ajax for the form:

$('.edit-account').submit ->

$.ajax({

type: this.method,

url: this.put,

data: $(this).serialize(),

success: ->

alert 'Success'

});

return false

The Accounts-Controller:

def update

@account = Account.find(params[:id])

if @account.update_attributes?(params[:account])

respond_to do |format|

format.js

end

end

end

Now, it does something, but the firebug-console shows this error:

Unknown action

The action 'update' could not be found for AccountsController

Routes are basically like this:

resources :users

resources :students

resources :schools

resources :accounts

What am I doing wrong?

Thank you in advance!

Edit:

I build a little workaround: Now, each button has a hidden queckbox, which is triggered on button-click. Via this way, it is possible to access the database. Works for the moment.

相关阅读:
Top