jinleileiking 发表于 2013-1-23 02:44:19

学习altered_beast 随笔

首先渲染layout/application.html.erb.....


    <li><%= link_to_function 'Search'[:search_title], "#", :href => root_path, :id => 'search-link' %></li>
search-link 在一个js里面定义。是ajax的内容,需要补补了:)

使用javascript的时候,通常我们会通过类似:
<a href="#" >提交</a>
的方式,通过一个伪链接来调用javascript方法.这种方法有一个问题是:
虽然点击该链接的时候不会跳转页面.但是滚动条会往上滚,解决的办法是返回一个false.
如下所示:
<a href="#" >提交</a>     <li><%= link_to 'Signup'[:signup_action], signup_path(:to => CGI.escape(request.request_uri)) %></li>signup_path(:to => CGI.escape(request.request_uri))


<%= yield :right %>

在erb中:
   <% content_for :right%>


<%= feed_icon_tag "Recent Posts"[:recent_posts], formatted_posts_path(:format => 'atom') %> ---AWDWR 3Ed
http://pinds.com/2006/07/26/rails-formatted-urls-in-simplyrestful/



    sites.reject { |s| s.default? }.first || sites.first


def ordered_forums(*args)    forums.ordered(*args)end

Post.table_name ---- table.name竟然是activerecord自带的东东。。找了半天。

has one, 是以@形式加进去的 forum.recent_post.created_at

forum @recent_post.created_at()




      <%= jstime forum.recent_post.created_at %><br />

显示:5days ago...原来是 他的class=time,用js搞的。。。。。没必要。


    @forum = current_site.forums.find_by_permalink(params[:id])

用了permalink_fu插件。。。

在model中
has_permalink :name
这样,就会自动的在数据库产生一个permalink字段,
若forum name为This is a Test, permalink = This-is-a-Test,不能有空格啊。

呵呵都是牛人啊。
页: [1]
查看完整版本: 学习altered_beast 随笔