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

Ola Bini

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

find(params[:id])
@layouts = Layout.find :all, :order => 'name'
end
def update
@path = Path.find(params[:id])
if @path.update_attributes(params[:path])
flash[:notice] = 'Path was successfully updated.'
redirect_to :action => 'show', :id => @path
else
@layouts = Layout.find :all, :order => 'name'
render :action => 'edit'
end
end
This is all you need to do to get the Path controller working as you want it to. The next step
is to change the views, and as it happens, they don??™t need much editing either. First of all, the
list view needs to be changed a little bit:

Listing paths




CHAPTER 7 ?–  A RAILS CMS 128





<% for path in @paths %>






<% end %>
NamePath
<%= link_to h(path.name),
{ :action => 'edit', :id => path }%>
<%= h path.path%><%= link_to 'Destroy', { :action => 'destroy', :id => path },
:confirm => 'Are you sure?', :post => true %>

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


<%= link_to 'New path', :action => 'new' %>
Second, the form for new and edit also needs to be changed.


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