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

Ola Bini

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

collect {|p| [ p.name, p.id ] },{}%>



You just add a select box over all style types in the same way you did with the paths.
That??™s all there is to the administration of styles. Try it out now!
Layouts
Editing layouts is much more interesting than the other parts we??™ve been discussing up until
now. Because a layout is basically an ordered list of styles, you need to have a good way to
order something. Ajax and the Prototype library will provide exactly what you need to accomplish
this. But first, begin as always by generating a scaffold.
Also as before, start by removing the show.rhtml and new.rhtml views. As usual, you??™ll
begin by adding the admin layout to the layouts controller. Also, remove the show action and
the new action. You won??™t do everything in the controller in one go, because the Ajax implementation
needs a few helpers. It makes more sense to look at those methods later. But first,
change the list action:
def list
@layout_pages, @layouts = paginate :layouts, :per_page => 10
@layout = Layout.new
end
Also, change the create action:
def create
@layout = Layout.new(:name => 'New layout')
if @layout.save
flash[:notice] = 'Layout was successfully created.'
redirect_to :action => 'list'
else
@layout_pages, @layouts = paginate :layouts, :per_page => 10
render :action => 'list'
end
end
The edit action needs to know which styles are available:
def edit
@layout = Layout.find(params[:id])
@styles = Style.


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