Rails 2.0中Fixtures简单多了,看个例子:
# products.yml
couch:
name: Couch
price: 399.99
manufacturer: lazyboy
categories: furniture
tv_stand:
name: TV Stand
price: 149.95
manufacturer: highdeph
categories: furniture, electronics
# manufacturers.yml
lazyboy:
name: LazyBoy
hig ...
项目地址:
http://rubyforge.org/projects/fckeditorp
安装:
rake fckeditor:install
引入js:
<%= javascript_include_tag :fckeditor %>
使用:
<%= fckeditor_textarea("object", "field", :width => '100%', :height => '500px') %>
老问题,js和css对跨浏览器兼容问题
在一台电脑上共存IE3 ~ IE7的方法:
先更新到IE7,然后下载安装下面的软件包
官方网站地址:http://tredosoft.com/Multiple_IE
下载地址如下:http://tredosoft.com/files/multi-ie/multiple-ie-setup.exe
Rails 2.0 里视图应该怎样写?
views/products/index.html.erb:
<%= render :partial => @products %>
views/products/show.html.erb:
<%= render :partial => @product %>
_product.html.erb:
<% div_for product do %>
<h2><%= link_to h(product.name), product %></h2>
...
<% end %>
...
添加如下JavaScript:
$.fn.enable_changed_form_confirm = function () {
var _f = this;
$('input[@type=text]', this).each(function() {
$(this).attr('_value', $(this).val());
});
$('input[@type=password]', this).each(function() {
$(this).attr('_value', $(this).val());
});
$('textarea', th ...
我们有如下三个近乎一样的named routes:
# routes.rb
ActionController::Routing::Routes.draw do |map|
map.about_company 'about/company', :controller => 'about', :action => 'company'
map.about_company 'about/privacy', :controller => 'about', :action => 'privacy'
map.about_company 'about/license', :contro ...
安装很简单
sudo apt-get install ssh
装完后自动启动ssh服务
在局域网路由器转发一下端口22就可以外网访问了
Part I: http://thinkweb2.com/projects/prototype-checklist/
1,错:
document.getElementById('foo')
对:
$('foo')
2,错:
var woot = document.getElementById('bar').value
var woot = $('bar').value
对:
var woot = $F('bar')
3,错:
$('footer').style.height = '100px';
$('footer').style.backgroun ...
首先是确认域名服务商提供泛域名服务
然后添加一条A记录"*.youdomain.com"到你的服务器IP的映射
Rails下判断subdomain时用request.subdomains[0]即可得到子域名
而在Firefox下cookie是按不同子域名存储的,所以需要在environment.rb里设置一下:
require 'action_controller'
ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:session_domain => ".yourdomain.com")
还有就是使用res ...
FF与IE7下input type="text" 和 input type="password"输入框的长度都是一样的,但在IE6下偏偏前面的长后面的短2px,设置size也不行,而设置width可以,但为了不影响其他input(如type=submit)的width,我们可以这样写css:
input[type="text"], input[type="password"] {
width: 200px;
}
input {
width: expression((this.type=="text" || this.type=="password") ? "200px" : ...
又回到这个老问题,表单输入中文时数据库数据为乱码
解决方案: MySQL字符集采用utf8,创建数据库时也使用utf8,然后在application.rb里加上:
# application.rb
before_filter :set_charset
before_filter :configure_charsets
def set_charset
@headers["Content-Type"] = "text/html; charset=utf-8"
end
def configure_charsets
@response.he ...
1,install
gem install pdf-writer
2,require & register
# environment.rb
require 'pdf/writer'
Mime::Type.register 'application/pdf', :pdf
3,use
# lib/product_drawer.rb
def self.draw(products)
pdf = PDF::Writer.new
products.each do |product|
pdf.text product.name
end
pdf ...
开启远程桌面服务在:我的电脑--》属性--》远程,选中checkbox即可
而穿越局域网也没啥,设置路由器将3389端口映射过来就行了
客户端在:开始--》程序--》附件--》通讯--》远程桌面连接
第一次感觉windows如此好用,哈哈
- 20:12
- 浏览 (863)
- 评论 (0)
我希望做一个demo server,每隔3分钟自动更新svn服务器上的代码,于是有了如下代码:
loop do
system 'svn up'
sleep(180)
end
哈哈,现在我可以只管向svn服务器提交代码了,demo server会自动更新不是么?
既然达到上述目标了,我们可以考虑用Rails做一套Rails项目开发的Web IDE,界面模仿RadRails,左侧弄个树形结构Navigator,右边是代码区域,css应该做不了根据页面内容来改变颜色这种纳米级别的控制,那么根据ruby语法来改变颜色我们需要一个模板render库。
Web IDE的好处是B/ ...
一、DIV标记与SPAN标记
div和span都可以作为一个容器,集体控制容器内的样式
区别是div使块级元素,前后会有换行
而span是行内元素,前后不会换行
div内可以有span,而span内不能有div
二、盒子模型
1,概念
任何页面元素都可以看成一个盒子
一个盒子模型由content、padding、border、margin四部分组成
width(height)的值指content的width(height)+padding的值
2,border
color
width: thin、medium、thick、数值
style: none、hidden、dotted、dashe ...
给div指定高度height并使用overflow属性来让它出现scrollbar样式:
<div style="border: solid 1px #ff0000; height: 200px; overflow: auto;">
1<br />
2<br />
3<br />
4<br />
5<br />
6<br />
7<br />
8<br />
9<br />
10<br />
11<br />
12<br />
13<br />
14<br />
15&l ...
- 浏览: 681922 次
- 性别:

- 来自: BJ

- 详细资料
搜索本博客
我的相册
screenshot
共 1 张
共 1 张
最近加入圈子
最新评论
-
Mnesia用户手册:三,构建 ...
要想创建disc_copies和disc_only_copies类型的表有两个前 ...
-- by hideto -
翻译www.djangobook.com之 ...
有个问题问一下: 我先配置了一个urlpatterns是这样的: r'^myd ...
-- by lyhapple -
Why OO sucks
gigix 写道lyl0035 写道为啥就没人想想,其实在面向对象的代码中也流露 ...
-- by hurd -
Why OO sucks
貌似又回到当年java vs c的年代。两种方式,不管是OO还是FP,仅是人处理 ...
-- by python -
大家可以抛弃Java踹死Djan ...
to phoenixup:1,你还别说,你举的什么Struts,Tapestry ...
-- by hideto






评论排行榜