11.2 show microposts.
- 博客分类:
- ruby and rails
1. add test to test the new users/show view:
describe UsersController do render_views . describe "GET 'show'" do before(:each) do @user = Factory(:user) end . . it "should show the user's microposts" do mp1 = Factory(:micropost, :user => @user, :content => "Foo bar") mp2 = Factory(:micropost, :user => @user, :content => "Baz quux") get :show, :id => @user response.should have_selector("span.content", :content => mp1.content) response.should have_selector("span.content", :content => mp2.content) end end . end
2. then work on the show page:
<table class="profile"> <tr> <td class="main"> . . . <% unless @user.microposts.empty? %> <table class="microposts" summary="User microposts"> <%= render @microposts %> </table> <%= will_paginate @microposts %> <% end %> </td> <td class="sidebar round"> <strong>Name</strong> <%= @user.name %><br /> <strong>URL</strong> <%= link_to user_path(@user), @user %><br /> <strong>Microposts</strong> <%= @user.microposts.count %> </td> </tr> </table>
note, we add a argument to will_paginate method.
because we are in users controller, so if the argument is @users, it can be omitted.
but this time, the argument is @microposts, so we need to specify it clearly.
3. then we need to add a _micropost.html.erb partial to views/microposts dir.
<tr> <td class="micropost"> <span class="content"><%= micropost.content %></span> <span class="timestamp"> Posted <%= time_ago_in_words(micropost.created_at) %> ago. </span> </tr>
5. we still need to add
@microposts = @user.microposts.paginate(:page => params[:page])
this will return a WillPaginate::Collection......
6. then we need to add some sample data to see the effect of our working.
50.times do User.all(:limit => 6).each do |user| user.microposts.create!(:content => Faker::Lorem.sentence(5)) end end
发表评论
-
12.3.3 scaling issue of the status feed
2011-10-30 17:54 742the problem of the implementati ... -
12.3 the status feed
2011-10-30 15:34 8081. we need to get all the micro ... -
12.2 a working follow button with Ajax
2011-10-29 18:10 8811. in the last chapter, in the ... -
12.2 a web interface for following and followers.
2011-10-28 22:14 8391.before we do the UI, we need ... -
12. following user, 12.1 relationship model
2011-10-18 14:29 7081. we need to use a relationshi ... -
11.3 manipulating microposts.
2011-10-17 15:31 8611. since all micropost actions ... -
11.1 user micropost -- a micropost model.
2011-10-17 10:43 10671. we will first generate a mic ... -
10.4 destroying users.
2011-10-16 15:47 691in this chapter, we will add de ... -
10.3 showing users list
2011-10-15 20:41 735in this chapter, we will do use ... -
10.2 protect pages.
2011-10-15 15:11 608again, we will start from TD ... -
10.1 updating users.
2011-10-14 18:30 6671. git checkout -b updating-use ... -
9.4 sign out
2011-10-13 15:21 687whew!!!, last chapter is a long ... -
9.3 sign in success.
2011-10-12 15:39 6901. we will first finish the cre ... -
9.1 about flash.now[:error] vs flash[:error]
2011-10-12 15:37 676There’s a subtle difference ... -
9.2 sign in failure
2011-10-12 12:19 610start from TDD!!! 1. requir ... -
9.1 sessions
2011-10-12 10:00 616a session is a semi-permanent c ... -
what test framework should you use?
2011-10-11 16:56 0for integration test, i have no ... -
what test framework should you use?
2011-10-11 16:56 0<p>for integration test, ... -
8.4 rspec integration tests
2011-10-11 16:53 679in integration test, you can te ... -
8.3 sign up success
2011-10-11 14:39 739Chapter 8.3 this part, we will ...
相关推荐
11.2.0.1升级到11.2.0.3.pdf11.2.0.1升级到11.2.0.3.pdf11.2.0.1升级到11.2.0.3.pdf
ojdbc6-11.2.0.3.jar 解压缩即可用
ojdbc6-11.2.0.1.0.jar,ojdbc6-11.2.0.1.0.jar,ojdbc6-11.2.0.1.0.jar
oracle 数据库 OPatch11.2.0.3.27版本,满足11G所有补丁包的需求版本,使用时先备份$ORACLE_HOME/Opatch,然后解压到替换$ORACLE_HOME/
maven管理Oracle时,在pom.xml配置了相关坐标消息,但到本地仓库com文件夹的Oracle中并没找到jar包,本资源提供了ojdbc6-11.2.0.1.0.jar下载。
ojdbc6-11.2.0.3.jar 使用maven 命令: mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar -Dfile=D:\xxxx\ojdbc6-11.2.0.3.jar将包安装在maven库中
x64位系统使用plsqldev必备的软件, instantclient-basic-nt-11.2.0.2.0.zip
instantclient-basic-windows.x64-11.2.0.4.0.zip,Oracle1164位官方客户端,可用于本地电脑未安装数据库的情况下,PLSQL连接Oracle数据库,注意,PLSQL也需要是64位版本的,客户端版本为11.2.0.4.0
Instant Client 11.2.0.4.0(Windows).rar 集成了所有的Oracle Instant Client Windows64位的包 包含以下包: instantclient-basic-windows.x64-11.2.0.4.0.zip instantclient-jdbc-windows.x64-11.2.0.4.0.zip ...
数据库驱动ojdbc6-11.2.0.1.jar
instantclient-basic-windows.x64-11.2.0.4.0.rar
OPatch 版本 OPatch-11.2.0.3.15 p6880880_112000_Linux-x86-64.zip 【不含有】ocm/bin/emocmrsp程序
oracle即时客户端 instantclient-basic-linux.x64-11.2.0.4.0.zip
在linux系统下看视频的必备软件 安装命令: rpm -ivh flash-plugin-11.2.202.491-release.x86_64.rpm
最新的opatch工具,版本是11.2.0.3.22 WINDOWS,给oracle 11g打最新补丁用的,不用从mos上下载了
ojdbc6.jar和orai18n-11.2.0.4.jar
linux 版 OPatch 11.2.0.3.23 版本比较新了,很多PSU 和CPU 补丁都需要这个版。积分设置得5分,不知道系统会不会调。
oracle官方64位-11.2.0.4.0版本客户端-instantclient-basic-windows.x64-11.2.0.4.0
Instant Client 11.2.0.4.0(Linux)集成了Linux 64位平台所有的Oracle Instant Client软件包 主要包含以下包: instantclient-basic-linux.x64-11.2.0.4.0.zip instantclient-jdbc-linux.x64-11.2.0.4.0.zip instant...
出现oracle jar包导不进的问题时,进入jar包所在目录 cmd管理员权限运行 ...mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.4.0 -Dpackaging=jar -Dfile=ojdbc6.jar