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 277 | Next

Ola Bini

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

next(params[:id], @user)
flash[:notice] = "Next for '#{params[:id]}': #{val}."
redirect_to :action => :show, :id => params[:id]
end
def create
if params[:id]
SequenceManager.create(params[:id], @user)
flash[:notice] = "Ensured sequence '#{params[:id]}' exists"
end
redirect_to :action => :list
end
You make sure that the actions that change the current value of a sequence report this
in the flash. Except for that, there??™s nothing to this controller.
The views aren??™t much more complicated. The first one, list, should look like this:

Sequences



    <% for seq in @sequences %>

  • CHAPTER 10 ?–  AN EJB-BACKED RAILS APPLICATION 190
    <%= link_to h(seq), {:action => 'show', :id => seq},
    :class => 'adminLink' %>

  • <% end %>

New sequence


<%= start_form_tag :action => 'create' %>

name="id" id="id"/>


<%= submit_tag "Create" %>
<%= end_form_tag %>
You have the form for creating a new sequence in the same page that lists all sequences,
because it just contains one small part. The only wrinkle in this list is that you don??™t have any
pagination of the results, which means you??™ll get all results in one page, regardless of how
many there are. On the other hand, there shouldn??™t be that many sequences available at that.
To show a sequence, you use the show.rhtml view:

Sequence: <%= h @sequence.name %>


Current: <%= h @sequence.value %>


Last updated: <%= h @sequence.


Pages:
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289