Ruby学习笔记6: 动态web app的建立(3)--多Model之间的交互

We first built a static site which displayed a static image using only a Controller and a View. This is our Etsy landing page page. Then we built the Categories page, with a Model (manages data), Controller (manages decisions) and View (manages display). The Categories pages allows us to display dynamic content so users can browse through different Categories that can be updated regularly. Now we will build the Products page, which will allow users to browse through Products in our Etsy app.

READ MORE

Ruby学习笔记5: 动态web app的建立 (2)

上一节里,我们搭建了一个数据库的结构,并用index验证了request-response cycle,如下图: 1. Add show method into Controller 这一节,我们要继续丰富我们的controller: While index gave all categories, show allows us to access one category. This this is helpful when we want to show just one Category at a time in our Etsy app. The show method works like this. we write: [ruby] view plaincopy def show    @category = Category.find(params[:id])    #it's a hash that we use to find an object by its unique id end  The show method finds a single category of a given id and stores it in @category.

READ MORE

Ruby学习笔记4: 动态web app的建立

Ruby学习笔记4: 动态web app的建立 We will first build the Categories page. This page contains topics like Art, Home & Living, and Kids, so our users can browse through categories and find what they like. Each Category in our site will need to store information about itself, such as a name and an image. Our Category Model is what stores information about our Categories. Remember that our Model manages the data in our app. =============================== 1. Build Model 2. Build Migration Table

READ MORE

Ruby学习笔记3:Rendering(渲染)和 Redirect(重定向)

1. Rendering Rendering 是特别要告诉Controller 中的methods,要哪个view file来显示给用户。We can show Views as we wish! Earlier each one of our Views rendered based on the method specified in the Controller. If we write the following method: def render_demo end Rails will always look for the render_demo View. But if we write: def render_demo render :home end We can tell Rails to render the home View, as long as we have one. Rendering just tells Rails to show the View we specify. 这里这个例子是这样的:

READ MORE

对互联网垂直社交产品的分析

社交产品是对每个个体自身人性的迎合、利诱和放大。如果说世界上最复杂的是人性,那么创业项目里最复杂的自然就是社交产品。互联网创业最有意思又最深奥的就是社交类产品。 一款好的社交产品一定是能够迎合人类七宗罪中的其中之一的,比如他觉得Facebook迎合的是傲慢/自负,人们把一些精挑细选的东西用粉饰后的方式表现给他们的关注者们,以此来获得一种虚荣感。 人类七宗罪(好色、暴食、贪婪、懒惰、愤怒、嫉妒、傲慢) 从七宗罪类型的人类原始需求出发的产品,好处是能够迅速吸引用户,形成病毒传播,但坏处是可持续性差,社区氛围维持难度高,和留存低。 更重要的是要像放风筝一样,利用七宗罪反过来的把社区向正面塑造。日常生活中的交往是一样的,哪怕你再喜欢一个人,也是要一步步循序渐进。 懂得生活的人,会从身边的旁枝末节中体会生活,而不是每天只高谈阔论。懂得追女孩子的人,与其每天都在献殷勤、表白和宣誓,不如找点事情一起做,找个共同话题一起聊天。容易交朋友的人,也是一样,都是有自己的兴趣和专长,这样大家才有话聊,才能在交谈中更加深入的了解彼此。 所有社交产品表面上要解决的核心问题只有一个,那就是牵线搭桥、制造媒介,最终让用户基于这个平台上的媒介形成更好的互动和关系的留存。 “知乎”给人们制造的媒介是问答 “YY”或“9158”给人们制造的媒介是视频娱乐内容 “豆瓣”给人们制造的媒介是影音书 “Nice”是潮流文化和标签式媒介 “陌陌”最早兴起的媒介其实就是地理位置因素 “会会”的媒介是用户的行业和背景与相约聊天的主题。 交往的过程需要这些媒介,要让用户之间有话聊,有源源不断的内容产生,内容消费,并且形成关系链条。 有甚者,有一些社交产品跳过了媒介,直接把人和人的关系引向了结果,比如直接可供任何人线下约饭的产品或是单纯根据照片挑选配对类的产品我都觉得是非常粗暴、违反人类正常交往习惯和不可持续的。 社交类产品还有一个需要注意的事情是“媒介的即时性”。 每种媒介的作用和效果都不同。媒介的选择非常重要,直接影响了最终产品和社区的形态。一种双向多边的,每个人都能低成本生产和消费内容的媒介才是最理想的。 垂直社交产品的意义并没有那么大。结果就是社交产品往往是几年出一个大的,也是个赢家通吃的市场。所以在最开始的时候就要想好抓的是用户的什么痛点和原始需求,又该用怎样的媒介来引导。 脉脉、会会、知乎、Linkedin、“Same”、“陪我”、“抱抱”

READ MORE

Ruby学习笔记2 : 一个简单的Ruby网站,搭建ruby环境

Ruby on Rails website 的基础是 请求-返回 循环。 首先是浏览器请求服务器, 第二步,Second, in our Rails application, the route takes the request and finds the right Controller and method to handle the request. 第三步,控制器拿到相关数据并发给View模块。 最后,View模块把数据打包好,并且发回给浏览器显示。 ----- 搭建开发环境: Creat rails file package: rails new my-appInstall Ruby gemsMaking a controller called pages 在routes.rb文件中,Create a routeCreate the View 1. Creat rails file package 操作 Rails 用的commands叫做Generator, 在Terminal里,使用如下命令可以新建一个rails app: rails new my-app rails就会建立一系列的站点文件。 然后我们在浏览器里输入:localhost:8000就能访问rails建立的第一个web 站点:   Let's learn about the files that you generated.来看看我们建立了哪些文件:   Rails is made up folders that hold our code:

READ MORE

Patrick Hughes - 错觉3D雕塑艺术

Pictures Patrick Hughes (artist) From Wikipedia, the free encyclopedia Patrick Hughes. Leaning on a Landscape, 1979, print. Patrick Hughes (born 20 Oct 1939)[1] is a British artist working in London. He is the creator of "reverspective", an optical illusion on a 3-dimensional surface where the parts of the picture which seem farthest away are actually physically the nearest. Contents   [hide]  1 Life2 Art3 Writing4 Influences5 Bibliography6 References7 External links Life[edit] Patrick Hughes was born in Birmingham, went to school in Hull and went on at the James Graham Day College in Leeds in 1959. Later he taught at the Leeds College of Artbefore becoming an independent artist.

READ MORE

Ruby学习笔记1 -- 基本语法和数据类型, Class

Ruby 有4种数据类型:String, Boolen, Array, Hashes Ruby 有3种操作方法:Method, attribute, ?? Ruby 有xxx: Classes, Object.... ====先来看数据类型==== 1. String and Declaring the variables:  name = "Wonder Woman" #declare a var and store a string puts name <span style="white-space:pre"> </span>#puts -- print out the var sum = 5 + 1.4 puts sum correct = 1 == 1 puts correct 2. Arrays: cities = ["chongqing","beijing","shanghai"] puts cities[1]; #print out the SECOND city 3.Hashes: 注意这句话:We can access any value by naming its key seasons = { "Spring" => 20, "Summer"=>30, "Autumn"=>20, "Winter"=>02} puts seasons["Winter"] #{ ?

READ MORE

Javascript学习笔记5 - 滑动Slides

开始之前:http://docs.jquery.com/ 是jQuery文档的网站, https://jsfiddle.net/是js的在线验证工具 在html中,有这几个标签:  javascript、jQuery代码:var main = function(){ $('.dropdown-toggle').click(function(){ //$('.dropdown-menu').slideDown(); $('.dropdown-menu').toggle(); }); // Click Slides -- Show next slide $(&#39;.arrow-next&#39;).click(function(){//select var currentSlide = $(&#39;.active-slide&#39;); var nextSlide = currentSlide.next(); if (nextSlide.length ===0) nextSlide = $(&#39;.slide&#39;).first(); currentSlide.fadeOut(600); nextSlide.fadeIn(600); currentSlide.removeClass(&#39;active-slide&#39;);//注意这里没有&quot;.&quot; nextSlide.addClass(&#39;active-slide&#39;); //让点点的颜色跟随变化 var currentDot = $(&#39;.active-dot&#39;); var nextDot = currentDot.next(); if (nextDot.length === 0) nextDot = $(&#39;.dot&#39;).first(); currentDot.removeClass(&#39;active-dot&#39;); nextDot.addClass(&#39;active-dot&#39;); }); // Click Slides -- show previous slide $(&#39;.arrow-prev&#39;).click(function(){//select var currentSlide = $(&#39;.active-slide&#39;); var prevSlide = currentSlide.prev(); if (prevSlide.length === 0) prevSlide = $(&#39;.slide&#39;).last(); currentSlide.

READ MORE

jQuery学习笔记4——A flipboard 剪贴板实例

jQuery学习笔记4——A flipboard 剪贴板实例 开始之前:jQuery文档(http://docs.jquery.com/) , js在线IDE(https://jsfiddle.net/),教程:(http://w3school.com.cn/) slideDown ——下滑 slideUp —— 向上滑 fadeIn —— 淡入 fadeOut —— 淡出 animate ——动画 takes two parameters: 1. A set of CSS properties, 2. A time duration over which to change them. 1. //*********关于slideDown和slideUp热身小程序********// 2. //=========点击从上往下出现========== 3. var main = function() { 4. $(".btn").click(function(event) { 5. $(".container").hide(); 6. $(".container").slideDown(900); 7. }); 8. }; 9. 10. $(document).ready(main); 11. 12. //=========点击从下往上出现========== 13. 14. var main = function() { 15. $(".btn").click(function(event) { 16. $(".container").show (); 17. $(".container").slideUp(1100); 18. }); 19.

READ MORE