SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 205 | Next

Ola Bini

"Practical JRuby on Rails Web 2.0 Projects: Bringing Ruby on Rails to Java"

So, change it
into this:
def create
@user = User.new(params[:user])
if @user.save
flash[:notice] = 'User was successfully created.'
redirect_to :action => 'list'
else
@user_pages, @users = paginate :users, :per_page => 10
render :action => 'list'
end
end
The only change here is that you provide the pagination parts for the list action, and
render list instead of new. The destroy method is good as it is, so now it??™s time to edit the view
files. The _form view is good as it is too, so the only thing you need to change is the file
app/views/users/list.rhtml:

Authenticated users




CHAPTER 7 ?–  A RAILS CMS 126





<% for user in @users %>






<% end %>
UsernamePassword
<%= h user.username %><%= h user.password.gsub(/./,'*') %> <%= link_to 'Remove', { :action => 'destroy', :id => user },
:confirm => 'Are you sure?', :post => true %>

<%= link_to 'Previous page', { :page =>
@user_pages.current.previous } if @user_pages.current.previous %>
<%= link_to 'Next page', { :page =>
@user_pages.current.next } if @user_pages.current.next %>


New user


<%= start_form_tag :action => 'create' %>
<%= render :partial => 'form' %>
<%= submit_tag "Create" %>
<%= end_form_tag %>
This view looks very much like the one for Shoplet users, actually.


Pages:
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217