というのも行政書士試験の勉強していたので・・・(以下略
とりあえず試験は終わったので
仕事の息抜きにAkelos触る時間が増やすつもりなんでー
間違いがあって、ご指摘いただいた点も直します_(._.)_
【どうでもいいことの最新記事】
続いて、読み出しの指定を書きます。show()アクションが書いてあるところを探してください。
下記のようになっているはずです。
-------------------------------------------------------
function show()
{
$this->post = $this->Post->find(@$this->params['id']);
}
-------------------------------------------------------
となっているところを
↓
-------------------------------------------------------
function show()
{
$this->post = $this->Post->find(@$this->params['id'],array('include'=>'comment'));
}
-------------------------------------------------------
と書き換えてください。末尾のところがポイントです。何を取り込む(include)するかを指定します。
ということで、ユーザ認証を前回までに作ったBlogチュートリアルのサイトに組み込んでみようかと思う。
方向性としては、new Post、Edit、Deleteにユーザ制限を加え、ユーザ登録した人だけがこれらのアクションに触れるようにする。
function __construct()
{
// beforeFilterで、自動的にApplicationControllerの_authpageメソッドを呼ぶように指定。
//認証済みユーザのみの制限をかけたいアクションを指定している。
$this->beforeFilter(array('_authpage'=>array('only'=>array('add','edit','destroy'))));
}
<%= error_messages_for 'user' %>
<p>
<label for="user_name">_{Name}</label><br />
<%= input 'user', 'name' %>
</p>
<p>
<label for="user_passwd">_{Passwd}</label><br />
<%= password_field 'user', 'passwd' %>
</p>
<p>
<label for="user_passwd_confirmation">_{passwd confirmation}</label><br />
<%= password_field 'user', 'passwd_confirmation' %>
</p>
<p>
<label for="user_email">_{Email}</label><br />
<%= input 'user', 'email' %>
</p>
<p>
<label for="user_is_enable">_{Is enable}</label><br />
<%= input 'user', 'is_enable' %>
</p>
<div id="sidebar">
<h1>_{Tasks}:</h1>
<ul>
<li><%= link_to _('Back to user index'), :action => 'index' %></li>
</ul>
</div>
<div id="content">
<h1>_{Users}</h1>
<p>_{Are you sure you want to delete this User?}</p>
<%= start_form_tag :action => 'delete' %>
<%= confirm_delete %>
</form>
</div>
<div id="sidebar">
<h1>_{Tasks}:</h1>
<ul>
<li><%= link_to _('Back to user index'), :action => 'index' %></li>
</ul>
</div>
<div id="content">
<h1>_{Account Page Index}</h1>
<p><%= link_to _('Login page'), :action =>'login' %></p>
<p><%= link_to _('New regist page'), :action =>'regist' %></p>
<p><%= link_to _('Remind password page'), :action =>'remind' %></p>
<p><%= link_to _('New regist page'), :action =>'regist' %></p>
<h1>_{Account Page Index}</h1>
<p><%= link_to _('Logout'), :action =>'logout' %></p>
<p><%= link_to _('Modify account profile'), :action =>'modify' %></p>
<p><%= link_to _('Delete account'), :action =>'delete' %></p>
<h1>_{Admin Page Index}</h1>
<p><%= link_to _('Userlist'), :action =>'listing' %></p>
</div>
<div id="sidebar">
<h1>_{Tasks}:</h1>
<ul>
<li><%= link_to _('Back to user index'), :action => 'index' %></li>
</ul>
</div>
<div id="content">
<h1>_{Users}</h1>
<p>_{Account Logout}</p>
<%= start_form_tag :action => 'login' %>
<p>
<label for="user_email">_{Email}</label><br />
<%= input 'user', 'email' %>
</p>
<p>
<label for="user_passwd">_{Passwd}</label><br />
<%= password_field 'user', 'passwd' %>
</p>
</form>
</div>
<div id="sidebar">
<h1>_{Tasks}:</h1>
<ul>
<li><%= link_to _('Back to user index'), :action => 'index' %></li>
</ul>
</div>
<div id="content">
<h1>_{Users}</h1>
<p><%= link_to _('Logout'), :action =>'logout' %></p>
</form>
</div>
<div id="sidebar">
<h1>_{Tasks}:</h1>
<ul>
<li><%= link_to _('Back to user index'), :action => 'index' %></li>
</ul>
</div>
<div id="content">
<h1>_{Users}</h1>
<%= start_form_tag :action => 'modify' %>
<div class="form">
<h2>_{Editing User}</h2>
<%= render :partial => 'form' %>
</div>
<div id="operations">
<%= save %> <%= cancel %>
</div>
</form>
</div>
<div id="sidebar">
<h1>_{Tasks}:</h1>
<ul>
<li><%= link_to _('Back to user index'), :action => 'index' %></li>
</ul>
</div>
<div id="content">
<h1>_{Users}</h1>
<%= start_form_tag :action => 'regist' %>
<div class="form">
<h2>_{User Profile}</h2>
<%= render :partial => 'form' %>
</div>
<div id="operations">
<%= save %> <%= cancel %>
</div>
</form>
</div>
<div id="sidebar">
<h1>_{Tasks}:</h1>
<ul>
<li><%= link_to _('Back to user index'), :action => 'index' %></li>
</ul>
</div>
<div id="content">
<h1>_{Users}</h1>
<%= start_form_tag :action => 'remind' %>
<div class="form">
<h2>_{User Profile Regist}</h2>
<p>
<label for="user_email">_{Email}</label><br />
<%= input 'user', 'email' %>
</p>
</div>
<div id="operations">
<%= save %> <%= cancel %>
</div>
</form>
</div>
<div id="sidebar">
<h1>_{Tasks}:</h1>
<ul>
<li><%= link_to _('Back to user index'), :action => 'index' %></li>
</ul>
</div>
<div id="content">
<h1>_{Users}</h1>
<h2>_{Thank you for regist!}</h2>
<p>
<%= link_to _('Back to user index'), :action => 'index' %>
</p>
</form>
</div>
<?php
// You can find more about routes on /lib/AkRouters.php and /test/test_AkRouter.php
$Map->connect('/account/', array('controller' => 'account', 'action' => 'index'));
$Map->connect('/', array('controller' => 'blog', 'action' => 'listing'));
$Map->connect('/:controller/:action/:id', array('controller' => 'blog', 'action' => 'listing'));
?>
Ak::import_mailer('notifymail');
$m = new Notifymail();
$m->deliver('regist',$this->User);
Ak::import_mailer('notifymail');
$m = new Notifymail();
$m->deliver('remindpassword',$u);
{User.name} 様
ご登録ありがとうございました。
以下の内容で登録が完了しましたのでご連絡いたします。
お名前:{User.name}
パスワード:{User.passwd_confirmation}
ご登録メールアドレス: {User.email}
==========================
サンプルサイト
example@sample.com
==========================
{User.name} 様
パスワードを再発行しました。
パスワード:{User.passwd_confirmation}
==========================
サンプルサイト
example@sample.com
==========================
| 日 | 月 | 火 | 水 | 木 | 金 | 土 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |