Sterling Rose Design Blog
Using AJAX to Change a User's Role
Authored by Dana Jones
February 09, 2009 17:26
2 Comments
Tags: Rails AJAX
Authored by Dana Jones
February 09, 2009 17:26
2 Comments
Tags: Rails AJAX
Scenario: Client wants to display a list of users, and the role each user currently has. The user’s role should be the selected option in a select box of all roles. Administrator should be able to update the user’s role by simply selecting a new role from the select box for that user, without having to reload the page.
Approach: Each row in the user’s list should have an id that uniquely identifies it as being associated with that particular user. Each select box should also have an id field associated with the user. Choosing a new role should trigger the
Code:
Read the whole post...Approach: Each row in the user’s list should have an id that uniquely identifies it as being associated with that particular user. Each select box should also have an id field associated with the user. Choosing a new role should trigger the
onchange event, which executes the update on the role and displays the new user’s row in place, without reloading the entire user list.Code:
## app/views/users/index.html.erb
<table>
<% @users.each do |u| %>
<tr id='user_row_<%= "#{u.id}" %>'>
<td><%= link_...
eWeek Covers Rails 2.3 RC 1
Authored by Dana Jones
February 02, 2009 22:39
0 Comments
Tags: Rails media
Authored by Dana Jones
February 02, 2009 22:39
0 Comments
Tags: Rails media
Darryl K. Taft of eWeek asked several of us who tweet about Rails what we thought about yesterday’s release of Rails 2.3 Release Candidate 1. Here is the article, along with my own thoughts.

