Nathan
Nathan

Reputation: 61

Is there a better way to make a button that changes an attribute in rails?

I'd like to make a button on a view page that changes an attribute in my database. I know how to do it via a form (but we don't want to do that) and I have used a convoluted ajax method to do it (which is just overly complicated), but it seems like there has got to be a better way.

Upvotes: 0

Views: 54

Answers (1)

dcow
dcow

Reputation: 7985

Nope (to a better way).

Q: How do you change a value in the database?

A: You have to send a[n] HTTP request to your server.

What are your options for sending HTTP requests to a server?

  1. Submitting a form and having the server respond with a new view.
  2. An asynchronous Javascript call with either XML or JSON (AJAX or AJAS)

You could write your own Javascript to do the "AJAX", or your would just use what's already out there.

Upvotes: 1

Related Questions