上一页 1 ··· 7 8 9 10 11 12 13 下一页
摘要: 1、Rails的国际化根据特定的locale信息,提取相应的内容通过config/environment.rb,指定应用的转换文件 config.i18n.load_path +=Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')] #指定搜索的文件类型 config.i18n.default_locale =:zh #指定默认的文件在config/locales中创建zh文件,提供转换的方式2、validates用于校验validates_presence_of 确认属性值不为nil也不为空va 阅读全文
posted @ 2013-08-03 23:31 wangyuyu 阅读(581) 评论(0) 推荐(0)
摘要: strip_tags(html)Strips all HTML tags from the html, including comments. This usesthe html-scanner tokenizer and so its HTML parsing ability is limited bythat of html-scanner.Examples strip_tags("Strip these tags!") # => Strip these tags! strip_tags("Bold no more! See more here...&q 阅读全文
posted @ 2013-08-03 23:30 wangyuyu 阅读(803) 评论(0) 推荐(0)
摘要: 一般来说,通常使用input的field都会做一些filter的动作,避免被不怀好意之徒塞一些危险的HTML code(script等)进去搞破坏。在ROR中,我们在前面加一个h()(一般不用括号?不容易看到?)即可,h在ROR中起什么作用呢?他是html_escape的alias(别名),他会将所有的""变成<,&gt,比如:js 代码 会变成: <script>alert('a');</script>这样就完全做不了乱了。因为所有的tag都被搞掉了。这样太严格了,有时候我们需要 阅读全文
posted @ 2013-08-03 22:41 wangyuyu 阅读(873) 评论(0) 推荐(0)
摘要: image_tag(source, options={}) LinkReturns an HTML image tag for thesource. The source can be a full path or a file.OptionsYou can add HTML attributes using theoptions. The options supports three additionalkeys for convenience and conformance::alt - If no alt text is given, the file name part of thes 阅读全文
posted @ 2013-08-03 22:35 wangyuyu 阅读(1191) 评论(0) 推荐(0)
摘要: render 先上点搜集的常用方式[ruby] view plaincopyprint?render :action => "long_goal", :layout => "spectacular" render :partial => "person", :locals => { :name => "david" } render :template => "weblog/show", :locals => {:customer => Custo 阅读全文
posted @ 2013-08-03 22:32 wangyuyu 阅读(12347) 评论(0) 推荐(0)
摘要: x.指定端口启动rails项目ruby script/server webrick -p 3000------------------------------------------------- 0.创建一个项目 rials demoshop ------------------------------------------------- 1.用脚手架创建产品(控制 模型 显示 数据) script/generate scaffold product title:string description:text image_url:string ----------------------- 阅读全文
posted @ 2013-08-03 22:20 wangyuyu 阅读(848) 评论(0) 推荐(0)
摘要: 自己很初级,初级的不能再初级,所以初次接触rails的时候,对于里面的create,new,build等方法不是很了解,用的很混乱,导致经常出现不必要的bug,很苦恼,决定,总结一下,结合网上已有资源,深入理解下 向数据库插记录时经常会用到new, build, create。这三个方法很容易混淆 save:rails中的save其实是create_or_update,新建或修改记录!不一定是新建,切记 new :只是在内存中新建一个对象,操作数据库要调用save方法。 create = new + 执行sql。 build:与new基本相同,多用于一对多情况下。还有一个不同请看使用示例 .. 阅读全文
posted @ 2013-08-03 21:50 wangyuyu 阅读(6069) 评论(0) 推荐(0)
摘要: 一、开始ActiveAdmin Active Admin是一个发布在RAILS3中使用的Gem。 1、我们为了快速开始我们对Active Admin的了解,我们首先安装它:在你GemFile中添加gem 'activeadmin'2、更新你的Gembundle install3、运行installerrails generate active_admin:install4、安装的installer会创建一个initializer,这个initializer采用Active Admin默认的配置,把所有需要的配置都写进一个文件夹app/admin里面。同时,这个时候会显示相关的配 阅读全文
posted @ 2013-08-02 15:39 wangyuyu 阅读(1043) 评论(0) 推荐(0)
摘要: mongodb与mysql命令对比传统的关系数据库一般由数据库(database)、表(table)、记录(record)三个层次概念组成,MongoDB是由数据库(database)、集合(collection)、文档对象(document)三个层次组成。MongoDB对于关系型数据库里的表,但是集合中没有列、行和关系概念,这体现了模式自由的特点。MySQLMongoDB说明mysqldmongod服务器守护进程mysqlmongo客户端工具mysqldumpmongodump逻辑备份工具mysqlmongorestore逻辑恢复工具db.repairDatabase()修复数据库mysql 阅读全文
posted @ 2013-08-01 12:04 wangyuyu 阅读(473) 评论(0) 推荐(0)
摘要: 运行dev@ubuntu:~/qq$ rails server出错[2013-07-30 16:29:23] WARN TCPServer Error: Address already in use - bind(2)Exiting/home/dev/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/webrick/utils.rb:85:in `initialize': Address already in use - bind(2) (Errno::EADDRINUSE)解决办法:终端运行 dev@ubuntu:~/qq$ lsof|grep 3 阅读全文
posted @ 2013-07-30 16:42 wangyuyu 阅读(759) 评论(0) 推荐(0)
上一页 1 ··· 7 8 9 10 11 12 13 下一页