- 博客(121)
- 问答 (2)
- 收藏
- 关注
万恶的"delete",慎用数组的delete
一直以来我的网站存在着一个令人很崩溃的问题。就是用户上传的图片会丢失。而且是连带相册一起丢失。开始还以为是什么地方误删了,冲突了。查了很久很久无果。关键是这个BUG并不是一定出现。而且,我测试时就从来没碰到过。 昨天一个用户刚注册,开始上传图片。我就密切注意。过了一会儿,果不然,相册丢失了。很纳闷。打开production.log看了N久。没发现异常啊。注:里面我没加sql的lo...
2009-01-09 00:16:27 565
修改edit_in_place插件,将“(点击编辑)”放入内容中
edit_in_place确实是个不错的效果。但是对于 主流用户 来说,输入框还有优于它的。为什么呢?因为你EIP在那,很多人不知道是可以点击修改的。好吧。你说后面加个提示,行,然后发现用户华丽的去点后面的提示,发现不能改……不知道本身这个插件有没有这个功能。没找到。知道的望告诉一下那么,我们就把提示放进内容中吧。我用的代码比较HARD,以后再更新,先能用。打开jrails_in_...
2008-12-24 13:52:51 436
原创 #125 Dynamic Layouts
Discover how to dynamically change the layout using content in the database. Check out this episode for details.[code="java"]script/generate migration add_layout_to_blogs layout_name:string custom...
2008-12-13 21:41:10 140
原创 #124 Beta Invitations
You know those invitation systems where a given user can invite a number of other people to join? That's what I show you how to make in this episode.[code="java"]script/generate nifty_scaffold inv...
2008-12-13 21:37:06 139
原创 #123 Subdomains
Learn how to unleash the full potential of subdomains with the subdomain-fu Rails plugin in this episode.Domain Name SolutionsAs mentioned in the episode, you’ll need to add each subdomain to ...
2008-12-13 15:56:37 231
原创 #122 Passenger in Development
Tired of juggling multiple Rails apps around with script/server? See how to set up Passenger in development so each one has its own local domain name.Sorry to make this platform specific. It looks l...
2008-12-13 15:51:19 135
原创 #121 Non Active Record Model
This episode will show you how to make a model which isn't based on Active Record. You may want to do this if a resource isn't backed by the database.[code="java"]# models/letter.rbclass Letter...
2008-12-13 15:47:32 112
原创 #120 Thinking Sphinx
If you need a full text search engine, Thinking Sphinx is a great solution. See why in this episode.[code="java"]script/plugin install git://github.com/freelancing-god/thinking-sphinx.gitrake th...
2008-12-12 16:59:56 93
原创 #119 Session Based Model
If you have a lot of logic associated with the data inside a session, you'll need some central location to put this logic. See how to create a session based model in this episode.[code="java"]# mo...
2008-12-12 16:41:54 100
原创 #118 Liquid
Liquid is a safe way to provide a powerful template language to the site's users. See how in this episode.[code="java"] @page %># environment.rbconfig.gem 'liquid'# application_helper....
2008-12-12 16:18:24 121
原创 #117 Semi-Static Pages
Static pages can sometimes be a little awkward to add to a Rails app. See a couple different solutions to this problem in this episode.[code="java"]# pages_controller.rbdef show if params[:perm...
2008-12-12 14:20:43 105
原创 #116 Selenium
Selenium is a great way to test your app automatically through a browser. See how it works in this episode.[code="java"]script/plugin install git://github.com/ryanb/selenium-on-rails.gitscript/gen...
2008-12-12 14:11:15 93
原创 #115 Caching in Rails 2.1
Rails 2.1 brings some new caching features which makes it very easy to cache any values including models. See how in this episode.[code="java"]# script/consoleRails.cache.write('date', Date.today)...
2008-12-12 14:07:54 112
原创 #114 Endless Page
Ever wondered how some sites seem to have endless scrolling page with no pagination? Find out how easy it is to do this in Rails in this episode.[code="java"]# products_controller.rbdef index @...
2008-12-12 13:50:11 164
原创 #112 Anonymous Scopes
The scoped method allows you to generate named scopes on the fly. In this episode I show how to use anonymous scopes to improve the conditional logic which was used in the previous episode on advanced...
2008-12-12 13:32:13 128
原创 #111 Advanced Search Form
If you need to create an advanced search with a lot of fields, it may not be ideal to use a GET request as I showed in episode 37. In this episode I will show you how to handle this by creating a Sear...
2008-12-12 13:27:01 144
原创 #110 Gem Dependencies
In Rails 2.1 we now have the ability to set gem dependencies. Now it's easier than ever to specify which ruby gems our rails app relies on.[code="java"]# config/environment.rbconfig.gem "RedCloth"...
2008-12-12 12:57:39 93
原创 #109 Tracking Attribute Changes
Rails 2.1 keeps track of the changes you make to a model's attributes. It also allows you to see what the previous value was. But watch out for the gotcha! See this episode for details.[code="java"]...
2008-12-12 12:54:41 106
原创 #108 named_scope
The named_scope method in Rails 2.1 makes performing finds on models very elegant and convenient. See how in this episode.[code="java"]# models/product.rbclass Product < ActiveRecord::Base belo...
2008-12-12 12:52:26 103
原创 #107 Migrations in Rails 2.1
Migrations now have a timestamp as their version number in Rails 2.1. In this episode I will explain this change as well as show you some other cool additions.[code="java"]# in a migration filedef...
2008-12-12 12:49:07 74
原创 #106 Time Zones in Rails 2.1
In the past, time zones have been very difficult to work with, but no longer! Rails 2.1 brings with it great time zone support as you can see in this episode.[code="java"]rake time:zones:local...
2008-12-12 12:48:11 120
原创 #104 Exception Notifications
If you're running a production site, it's a good idea to record all exceptions which occur. See how to set up a notification system which does that in this episode.Note: I forgot to mention, the exc...
2008-12-12 11:48:10 109
原创 #103 Site Wide Announcements
Sometimes you need to display an administrative announcement to every page on the site and give the users the ability to hide the announcement. See how in this episode.[code="java"]script/generate s...
2008-12-12 11:42:29 206
原创 #102 Auto-Complete Association
Usually a select menu is used for setting a belongs_to association, but in this episode I will show you how to use a text field with auto completion.[code="java"]script/plugin install auto_complete...
2008-12-12 11:34:33 105
原创 #101 Refactoring Out Helper Object
If you have complex view logic, this can easily lead to helper methods which call each other. See how to refactor this out into another object in this episode.[code="java"]# application_helper.rbd...
2008-12-12 11:31:37 97
原创 #100 5 View Tips
Tip #1: Whitespace in ERB TemplatesUse a dash at the beginning and end of an ERB tag to remove the white space around it.[code="java"] [/code]Tip #2: content_for :sideYou ca...
2008-12-11 21:20:46 76
原创 #99 Complex Partials
How do you handle partials which have differences depending on the action which is rendering them? Here's three suggestions for this problem.[code="java"] 'article', :object => article do %>...
2008-12-11 21:12:22 88
原创 #98 Request Profiling
You can use profiling to determine where the performance bottlenecks are in specific Rails actions. Watch this episode for details.[code="java"]# config/environments/staging.rbconfig.cache_classes...
2008-12-11 21:08:14 67
原创 #96 Git on Rails
Git has been getting a lot of buzz lately, and for good reason. It's an excellent SCM which in many ways is more simple and powerful than subversion. See how to set up a Rails project with Git in this...
2008-12-11 20:29:34 76
原创 #95 More on ActiveResource
See how to handle authentication and custom actions using ActiveResource in this episode.[code="java"]# models/product.rb (in blog app)class Product < ActiveResource::Base self.site = "http://a...
2008-12-11 20:27:58 91
原创 #94 ActiveResource Basics
ActiveResource allows you to easily communicate between multiple Rails applications. See how in this episode.[code="java"]# models/product.rbclass Product < ActiveResource::Base self.site = "ht...
2008-12-10 14:58:53 82
原创 #93 Action Caching
Action caching behaves much like page caching except it processes the controller filters. You can also make it conditional as seen in this episode.[code="java"]# products_controller.rbcache_sweepe...
2008-12-10 14:56:33 93
原创 #92 make_resourceful
The make_resourceful plugin is a great way to DRY up the 7 RESTful actions common in most controllers. Learn how to use it in this episode.[code="java"]# products_controller.rbmake_resourceful do...
2008-12-10 14:55:14 83
原创 #90 Fragment Caching
Sometimes you only want to cache a section of a page instead of the entire page. Fragment caching is the answer as shown in this episode.[code="java"]# products_controller.rbcache_sweeper :product...
2008-12-10 14:39:13 82
原创 #89 Page Caching
Page caching is an efficient way to cache stateless content. In this episode I will show you how to cache the dynamic javascript we created last week.[code="java"]# javascripts_controller.rbcaches...
2008-12-10 14:35:36 79
原创 #88 Dynamic Select Menus
See how to dynamically change a select menu based on another select menu using Javascript. In this episode everything is kept client side which leads to a more responsive user interface.[code="java"...
2008-12-10 14:33:30 146
原创 #87 Generating RSS Feeds
See how to easily generate and link to an RSS feed using new features in Rails 2.0. Watch this episode or details.[code="java"]# index.rss.builderxml.instruct! :xml, :version => "1.0" xml.rss :v...
2008-12-10 12:02:48 95
原创 #86 Logging Variables
Have you ever wanted to easily log all variables? Now you can by using some advanced Ruby concepts as shown in this episode.[code="java"]# models/product.rblogger.debug_variables(binding)# con...
2008-12-10 11:59:18 74
原创 #85 YAML Configuration File
Application configuration shouldn't be spread throughout your code base. Instead a much better place to put it is an external YAML file. See how to do that in this episode.[code="java"]# config/in...
2008-12-09 21:22:55 192
原创 #84 Cookie Based Session Store
In Rails 1.2 the default session store is file based. This is inefficient and difficult to maintain. In Rails 2.0 the default is now cookie based which has several benefits as you will see in this epi...
2008-12-09 21:11:52 68
空空如也
ROR中如何实现,用户某行为造成一个时间后的某个效果。
2008-08-29
事务中的两个模型存储,出错后如何得到验证信息?
2008-07-30
TA创建的收藏夹 TA关注的收藏夹
TA关注的人