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

Ola Bini

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

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




<%= select 'article', 'layout_id',
@layouts.collect {|l| [l.name, l.id]}, :include_blank => true %>




<%= select 'article', 'path_id',
@paths.collect {|p| [p.name, p.id]} %>



There??™s nothing strange here. You just add the associated values, with select boxes for
them. You also make sure that the captions for all fields are correct and descriptive.
This is all there is to articles. Go ahead and create some now! In the next chapter we??™ll take
a look at how to go about rendering the content created in this interface. First you have a more
pressing concern: security, or the lack thereof.
Some Security
We??™ve neglected that this should be an administrative user interface, which means it should be
protected. Of course, there is a model for users, and you??™ve added support for updating that,
but there is no real protection yet. However, as you might remember, it??™s simple to fix that. So,
create a new controller named AdminController. It should look like this:
class AdminController < ApplicationController
before_filter :authentication
private
def authentication
unless session[:user_id] && User.find_by_id(session[:user_id])
flash[:notice] = "Please log in"
CHAPTER 7 ?–  A RAILS CMS 139
redirect_to(:controller => 'auth', :action => 'login',
:into => url_for(params))
else
@loggedin = true
end
end
end
As you can see, the code is more or less the same as the authentication parts for the
Shoplet.


Pages:
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231