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

Ola Bini

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


Once again, the controller is finished, and you should go ahead and work on the views.
First of all, open up the list.rhtml file and edit it to look something like this:

Listing styles








<% for style in @styles %>





<% end %>
NameType
<%=link_to h(style.name), admin_url(
:controller => params[:controller],:action => 'edit',
:id => style)%>
<%=h style.style_type.name %><%= link_to 'Destroy', admin_url(
:controller => params[:controller], :action => 'destroy',
:id => style), :confirm => 'Are you sure?',
:post => true if style.stylings.empty?%>

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


<%= link_to 'Create new style', admin_url(:controller =>
params[:controller],:action => 'new') %>
As you can see, you??™ve used the admin_url helper again here. Also notice that you only
show the destroy link if the style has no associated stylings. That means you can only remove
a style that isn??™t used by anyone.
The _form.rhtml file doesn??™t need to change so much:
<%= error_messages_for 'style' %>



<%= text_field 'style', 'name' %>


CHAPTER 7 ?–  A RAILS CMS 131



<%= text_area 'style', 'data' %>




<%= select 'style', 'style_type_id',
@style_types.


Pages:
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222