您的位置:首页 > 大数据 > 人工智能

rails常用语法

2016-07-20 17:15 531 查看
1.附件列表

ul.m_item_list -@page.attachment_list('手机图片').eachdo|attachment| li =link_to'/posts/1',class:'wrap'do =image_tagamalgam.attachment_url(attachment) p.des =attachment.description p.type干红葡萄酒 .button =image_tag('button_details.jpg') /////=image_tagattachment.file.url

=properties_for@pagedo|p| #提供文本框修改@page对象的title =p.string'title' #提供文本框修改@page对象的content['title']属性 =p.string'content.title' #上传名为pic的附件 =p.attachment'pic' #上传名为pics的附件列表 =p.attachment_list'pics'

2.带有index的

-@page.children.each_with_indexdo|attachment,index|

3.自身与兄弟元素

-@page.parent.self_and_siblings.eachdo|sub_nav|

4.propertiesbutton

ul -Page.find_by_slug('tickets-top').children.eachdo|ticket| li =link_to(ticket.content['url']||'#',target:'_blank')do =editable_image_tagticket,'content.image',:display=>'245x162!',:placeholder_options=>{:width=>245,:height=>162} h3=ticket.title h2="¥#{ticket.content['price']}" .btn立即抢购 =properties_buttonticketdo|f| =f.string'title' =f.string'content.price' =f.string'content.url' =f.string'content.wap_url'

5.content_tag

=editable_content_tag:div,@page,'content.content',:class=>'article'do |

6.content_img

=editable_image_tag@page,:display=>'80x371!',:placeholder=>"position.png",:placeholder_options=>{:width=>80,:height=>371} 展位图不在本地时 =editable_image_tag@page,'content.produce_place',:display=>'262x202!',:placeholder_options=>{:width=>262,:height=>202}

7.home是举例子是文件夹

pages |--home |--&1.html.slim |--&2.html.slim 页面: |--home |--child1(home/&1.html.slim) |--child2(home/&1.html.slim) ||--grand_child(home/&2.html.slim)

8变量穿插

h2=
"¥#{ticket.content['price']}"


  =image_tag("tag_#{tag}.jpg")

9.日期

=order.created_at.strftime('%Y.%m.%d')

10.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: